I am using spring data Couchbase to connect to the Couchbase database from my spring boot application . And I am directly connecting to the Bucket using bucket name and password. But when there is any database maintenance(linux patching/db restart) then connection is getting break and it's not automatically restored when database maintenance is over. And I get "ConcurrentTimeout Exception". and I have to restart the application to connect to the database.
Is there any setting/configuration that I can do to restore the connection automatically?
version:
spring-data-couchbase :2.2.20.release and Couchbase server: 6.6
The java SDK will only try to connect for the duration specified by the kv connect timeout. To try for up to one hour, modified the couchbase environment by overriding the configureEnvironment() method in AbstractCouchbaseConfiguration.
#Override
protected void configureEnvironment(ClusterEnvironment.Builder builder) {
builder.timeoutConfig().connectTimeout(Duration.ofSeconds(3600));
}
In the 2.x SDK, I believe this would be
DefaultCouchbaseEnvironment.builder().socketConnectTimeout()
https://docs.couchbase.com/sdk-api/couchbase-core-io-1.7.12/com/couchbase/client/core/env/DefaultCoreEnvironment.Builder.html
Related
We have an application that uses several data sources. A DB underlying one of those data sources is down at the moment: IOError. Network adapter couldn't establish the connection & Socket read timed out.
Is there an annotation (or other means) of configuring Spring Boot such that it bypasses the culprit data source and still starts up: the DB is not essential in current development work. spring.datasource.continue-on-error=true doesn't seem to work. This is Spring 2.2.2.RELEASE.
using multiple datasource, so when your apps fail at start up your apps still work, i mean using memory db / sqlite to handle fail at connection error...
I want to configure my connection pool size for Spring Boot Couchbase application, but I can't find any property in order to set it.
A colleague suggested to use (in order to configure queryservice pool)
spring.couchbase.env.endpoints.queryservice.min-endpoints=1
spring.couchbase.env.endpoints.queryservice.max-endpoints=5
but when i do a netstat it doesn't work. i have 1 socket per node.
I am using spring boot.
I have been researching Spring Data Rest especially for cassandra and one of the questions my coworkers and I had was when does Spring Data connect to the database. We don't always want a rest controller to connect to the database so when does spring establish a connection if say we had a class extend the CRUDRepository? Does it connect to the database during the start of application itself? Is that something we can control?
For example, I implemented this example on Spring's website:
https://spring.io/guides/gs/accessing-data-rest/
At what point in the code does spring connect to the database?
Spring will connect to the DB as soon as the Datasource get initialized. Basically, Spring contexts will become alive somehow (Web listeners, manually calling them) and start creating beans. As soon as it reaches the Datasource, connection will be made and the connection pool will be populated.
Of course the above is based on a normal out of the box configuration and everything can be setup up to your taste.
So unless, you decide to control the connections yourself, DB connections will be sitting there waiting to be used.
Disagree with the above answer.
As part of research i initiated the datasource using a bean configuration and then changed my database password(not in my spring application but the real db username password)
The connection stays for a while and then in some point of time (maybe idle time) it stops working and throws credential exception.
This is enough to say the JPA does not keep the connection sitting and waiting to be used but uses some mechanism to occupy/release the db connection as per the need.
I'm using spring-data-redis, spring-session and Spring Boot to connect to my Redis instance. However I would like spring-data-redis to connect not to DB 0 (which is default) but to another local database (say DB 1). This is where I'd like the sessions to be stored. Is this possible with spring-data-redis?
The ConnectionFactory used by RedisTemplate offers configuration options for setting a default DB. Depending on the Redis driver in use both JedisConnectionFactory as well as LettuceConnectionFactory offer void setDatabase(int index).
Using Spring Boot RedisProperties allows to set the default DB via setDatabase or by providing spring.redis.database.
I have database username and password to access oracle db and also have service url like https://X-X.X.X.oraclecloudapps.com/apex/.
Can anybody know how to connect this db using JDBC connection.
I tried using oracle thin driver but somehow it failes.
Sample java code:
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:#//X.X.X.X.oraclecloudapps.com:1521/sid", "username", "****");
It throws
Exception in thread "main" java.sql.SQLRecoverableException: Io exception: The Network Adapter could not establish the connection
I don't know SID here, it would be helpful if anybody give steps to find SID/ServiceName from Oracle Cloud dashboard.
You can't use JDBC to connect to the Database Schema Service. You can connect using the API or tools that utilize the REST API. For data upload to Oracle Database Schema Service, use Oracle SQL Developer, the Oracle Application Express SQL Workshop Data Upload Utility or the Oracle Application Express Data Load utility. Read more here: http://docs.oracle.com/cloud/latest/dbcs_schema/CSDBU/GUID-3B14CF7A-637B-4019-AAA7-A6DC5FF3D2AE.htm#CSDBU177
There is only three way to connect Database Schema Service.
From an Oracle Application Express application running in Database Schema Service
From a Java application running in an Oracle Java Cloud Service
Through RESTful Web services
Try the following JDBC URL to resolve the issue
"jdbc:oracle:thin:#host-address:1521/sid";
Note / is used after port and Not :