I am making a jdbc connection to voltdb, how to make this connection TopologyChangeAware. over here i am using Hikari.
Finally got answer
For now, the jdbc client does not have a TopologyChangeAware property, but there is a similar one called autoreconnect that we can put into your connection URL.
It is described in the docs here:usingvoltdb jdbc
It looks something like this:
Connection c = DriverManager.getConnection(
"jdbc:voltdb://svr1:21212,svr2:21212?autoreconnect=true");
When set to true, the jdbc client will automatically try to reconnect to any nodes that disconnect until they rejoin the cluster.
Related
Currently, master-slave replication is finished, and select and insert are branched using the readwritesplit function of maxscale.
I was using common dbcp and checking the connection using the options of testOnBorrow and validationQuery through datasource configuration, but because the query is transmitted through maxscale, select 1 of validationQuery is only transmitted to the slave, and the connection validity of the master cannot be checked.
The master does not check the validity of the connection, so if you connect after not using WAS for a long time, a db connection related error occurs.
to solve this problem
I used master_accept_reads = true,
but I don't want to use it as it will generate more traffic to the master.
As another option persistpoolmax,persistmaxtime
I used, but I got the same error message.
I am wondering if there is a way to send a connection validation query such as ValidationQuery in maxscale or mariadb without distinction between master and slave.
Thank you for reading the long text.
You can use the hint filter to route queries to the master.
https://mariadb.com/kb/en/mariadb-maxscale-24-hintfilter/
I am trying to connect to Snowflake which only has port 443 open for communications using JDBC driver. Instead of directly connecting to the snowflake server I want to connect to it via tunnel server. So I've created a ssh tunnel from local machine to snowflake server. And I'm passing the forwarded local address and port as the host for the JDBC connection String. This is my final JDBC string.
jdbc:snowflake://127.0.0.1:21212/?db=TEST_DB&warehouse=LOAD_WH&user=<user>&password=<password>
but the JDBC driver is not able to establish connection and fails during SSL handshake. Since the host address in the JDBC connection string doesn't have the format of that of the CN and SAN present in snowflake's SSL certificate.
Adding the stacktrace along:-
javax.net.ssl.SSLPeerUnverifiedException: Certificate for <10.11.227.124> doesn't match any of the subject alternative names: [*.snowflakecomputing.com, snowflakecomputing.com]
at net.snowflake.client.jdbc.internal.apache.http.conn.ssl.SSLConnectionSocketFactory.verifyHostname(SSLConnectionSocketFactory.java:467)
at net.snowflake.client.jdbc.internal.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:397)
at net.snowflake.client.jdbc.internal.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355)
at net.snowflake.client.jdbc.internal.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at net.snowflake.client.jdbc.internal.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at net.snowflake.client.jdbc.internal.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at net.snowflake.client.jdbc.internal.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at net.snowflake.client.jdbc.internal.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at net.snowflake.client.jdbc.internal.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at net.snowflake.client.jdbc.internal.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at net.snowflake.client.jdbc.internal.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at net.snowflake.client.jdbc.internal.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at net.snowflake.client.jdbc.internal.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
at net.snowflake.client.jdbc.internal.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at net.snowflake.client.jdbc.RestRequest.execute(RestRequest.java:141)
at net.snowflake.client.core.HttpUtil.executeRequestInternal(HttpUtil.java:280)
at net.snowflake.client.core.HttpUtil.executeRequest(HttpUtil.java:234)
at net.snowflake.client.core.SessionUtil.openSession(SessionUtil.java:906)
at net.snowflake.client.core.SFSession.open(SFSession.java:330)
at net.snowflake.client.jdbc.SnowflakeConnectionV1.<init>(SnowflakeConnectionV1.java:239)
at net.snowflake.client.jdbc.SnowflakeDriver.connect(SnowflakeDriver.java:344)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:670)
at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
at org.apache.sqoop.tool.EvalSqlTool.run(EvalSqlTool.java:70)
at org.apache.sqoop.Sqoop.run(Sqoop.java:175)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:211)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:250)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:259)
at org.apache.sqoop.Sqoop.main(Sqoop.java:268)
at com.cloudera.sqoop.Sqoop.main(Sqoop.java:57)
Anyone has done similar thing in past and can guide me on how to do that?
By default snowflake JDBC driver will use tls for communication since snowflake is on public cloud, we have to verify certificate to trust the connection. However, in your case, you are trying to connect to a local server (I guess no tls there), you can add turn ssl off in the connection property. You can try
Properties prop = new Properties();
prop.put("account", "testaccount");
...
prop.put("ssl", "off");
Connection conn = DriverManager.getConnection(url, prop);
I am not sure if this would work or not, but I think worth trying.
Does SQL Azure allow 3-rd party connection pool like HikariCP or BoneCP?
We configured HikariCP it works when we just run app but later db doesnt response on request. Is it HikariCP issue or it's common connection poool issue and no need spending more time on investigation?
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(50);
config.setDriverClassName(env.getProperty("jdbc.driverClassName"));
config.setJdbcUrl(env.getProperty("jdbc.url"));
config.setUsername(env.getProperty("jdbc.user"));
config.setPassword(env.getProperty("jdbc.pass"));
config.addDataSourceProperty("cachePrepStmts", env.getProperty("jdbc.cachePrepStmts"));
config.addDataSourceProperty("prepStmtCacheSize", env.getProperty("jdbc.prepStmtCacheSize"));
config.addDataSourceProperty("prepStmtCacheSqlLimit", env.getProperty("jdbc.prepStmtCacheSqlLimit"));
config.addDataSourceProperty("useServerPrepStmts", env.getProperty("jdbc.useServerPrepStmts"));
See this SQL Azure page re: Connection Constraints.
Maximum allowable durations are subject to change depending on the resource usage.
A logged-in session that has been idle for 30 minutes will be terminated
automatically. We strongly recommend that you use the connection pooling and
always close the connection when you are finished using it so that the unused
connection will be returned to the pool. For more information about connection
pooling, see Connection Pooling.
See if any of these errors match up to your logs. Search that page for "terminated" and "busy" to find error codes that might be relevant to your issue.
I would suggest setting the maxLifetime property in HikariCP to 15 minutes, and the idleTimeout to 2 minutes.
There is nothing on the SQL Azure side that would prohibit you from using a 3rd party connection pool. My guess is that the connection failed between the server and the client and the client didn't remove the connection from the pool.
Moving forward, I'd ensure that whichever 3-rd part connection pool you end up using tests that the connection exists before taking it out of the pool for use.
Hope that helps.
I'm newbie to the orientdb, I'm using netbeans's (add new connection wizard) to add a connection to the orientdb, I used orientdb-jdbc-2.0.2-all.jar as a jdbc driver, but I got the following error after clicking on test connection
Snapshot of the error
I made sure that the database is connected and everything is right, any idea?
The URL should be jdbc:orient:remote:localhost/Sensor_Data
Look at the documentation: http://www.orientechnologies.com/docs/last/orientdb-jdbc.wiki/Home.html#first-get-a-connection.
the problem should be in the connection port. You are using 2480 (HTTP port) instead of 2424 (binary protocol).
I have multiple database connection in my Sinatra Application. It should switch the database intelligently according to the params.
For example:
get '/:project/details' do
...
end
It should connect to the database 'project1' if the url is 0.0.0.0:3000/project1/details, 'project2' if the url is 0.0.0.0:3000/project2/details, and so on.
I am using active_record for database connection.
I want to keep the connection in a pool, so that I can use the same connection if more than one hit to the same project. And shift the connection in the pool according to the project with out establishing a new connection for each each and every hit.
How to implement this?