Firebird JDBC connection pool validation on Payara server - jdbc

After a Firebird database crash the connections of the JDBC pool become invalid. (We have to flush the pool manually.) A good concept might be to use jdbc connection pool validation.
Connection validation properties
I am not sure what is the validation classname of the payara implementation, or in general what configuration works here. Is there a better way to handle the problem?

Thanks to Mark Rotteveel I have solved the problem. Also thanks for pointing out the importance of the jaybird driver upgrade. I used the following asadmin commands:
set resources.jdbc-connection-pool.jdbc_pool_name.connection-validation-method=custom-validation
set resources.jdbc-connection-pool.jdbc_pool_name.validation-classname=org.glassfish.api.jdbc.validation.JDBC40ConnectionValidation
set resources.jdbc-connection-pool.jdbc_pool_name.is-connection-validation-required=true
set resources.jdbc-connection-pool.jdbc_pool_name.fail-all-connections=true
In my case the main cause of the error was a Firebird segfault. The configurations above have passed the tests.

Related

Socket timeout property for db2jcc4 driver for db2 database using Hikari CP

I am connecting to Db2 database through spring boot application (2.1.2 release).. Hikari cp is the connection pool.. Db2 jdbc driver is db2jcc4 4.26.14 . I am receiving Error code - 4499:connection is reset message after my application runs for few days. On restart it starts working fine.
Found in one of the thread setting the socket timeout property may help. Can some one please let me know how to set the socket timeout property for db2 driver.
I have set maxLifetime as 130000, idleTimeout as 120000, ConnectionTimeout as 300000, minimumIdle as 0,maxPoolSize as 10.
Any help will be really appreciated to solve this issue.
Thanks in Advance.
At db2jcc4.jar level, different kinds of timeout settings are availble , and may depend on the target Db2-server-platform and Db2-server-version and HA configuration. Your question omits these facts about your environment.
Examples of settable attributes at db2jcc4.jar level for recent versions of this driver include these below:
blockingReadConnectionTimeout
commandTimeout
connectionTimeout
keepAliveTimeout
loginTimeout
memberConnectTimeout
queryTimeoutInterruptProcessingMode
timerLevelForQueryTimeOut
Detailed study is needed to comprehend these, and the related settings (and how they relate to Hikari level configuration), as well as comprehensive test coverage.
Documentation below:
https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.apdv.java.doc/src/tpc/imjcc_r0052038.html

spring boot datasource tomcat jdbc properties not working

I have a Spring Boot application (version 1.5.1.RELEASE) and I am using spring-boot-starter-data-jpa as a dependency to manage my database. I am using postgres as my database and configured it using the below properties.
spring.datasource.url=${POSTGRES_URL}
spring.datasource.username=${POSTGRES_USER}
Now when I run my tests which are almost 120, I get too many client already open error for abou 10 test cases while starting the test case itself and it fails.(remaining 100 test cases pass with success as they are able to get a connection to database)
First thing I did is increased my default postgres max connections count from 100 to 200 in the postgres server config file and my tests pass successfully after this change.
Now I investigated a bit and tried setting the parameters for connection pooling properties such as :
spring.datasource.tomcat.max-active=200
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.max-wait=10000
However these properties do not work and the tests fails again giving the same error as above. I tried reading from multiple different blogs and spring documentation for setting the connection pool properties but did not find what might be going wrong with me.
I also think that if I set the above property spring.datasource.tomcat.max-active to 100 connections it should work with the help of tomcat jdbc pooling as i think in current scenario it is trying to open a new connection to database for each test case and I am in a fear that this same scenario might happen when I deploy this code to production environment and a new connection will be opened to the database for each request.
Does anyone have faced this problem before or is there something wrong I am doing.
Thanks in advance for the help.
Try upgrading Spring boot version, 1.5.10-RELEASE is the current version.
Also, I found the connection pool properties for my application were not being applied when the property prefix tomcat was included. If you are still having issues try removing that.
i.e.
spring.datasource.tomcat.max-active=200
Becomes
spring.datasource.max-active=200
See https://artofcode.wordpress.com/2017/10/19/spring-boot-configuration-for-tomcats-pooling-data-source

Tomcat Connection Pool Concept & c3p0 connection pooling?

I have two Java Web Applications running under Tomcat (6.0) and using the Tomcat & c3p0 connection pool as Tomcat Data-source.If I define two Resources (server.xml) for two different Oracle Connection and use c3p0 for connection pool as below which my we applications use, my questions are:
<Resource
name="jdbc/OracleDB"
auth="Container"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
driverClass="oracle.jdbc.OracleDriver"
factory="xxx"
jdbcUrl="jdbc:oracle:thin:#(DESCRIPTION= (LOAD_BALANCE=on)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx) (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=xxx)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=xxx)))"
maxPoolSize="10"
minPoolSize="0"
maxIdleTime="60"
maxConnectionAge="600"
acquireIncrement="1"
user="xxx="
password="xxx=" />
<Resource name="jdbc/xxx2DB"
auth="Container"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
driverClass="oracle.jdbc.OracleDriver"
factory="xxx"
jdbcUrl="jdbc:oracle:thin:#xxx:1527:xxx"
maxPoolSize="10"
minPoolSize="0"
acquireIncrement="1"
maxIdleTime="60"
maxConnectionAge="600"
user="xxx"
password="xxx"
/>
Q1. Does the below in server.xml mean that two connection pools are existing in the Tomcat
memory to two different Oracle Instances?
Q2. Do I have to specify any configuration properties (ref:http://www.mchange.com/projects/c3p0/index.html#configuration_properties) , in my case I have a connection to an Oracle RAC instance and another to a single instance of Oracle. Should I take into account
any additional configuration properties in an enterprise environment ?
Q3. Are the below setting valid enough?
Q4. How do I enable c3p0 logging (i have only the jar in Tomcat lib and the above setting for now?
Any advice?
Thanks in advance.
A1: Yes.
A2: Not sure if I got the question right, but you should only specify those connection properties which defaults do not make sense to you. It's probably best to do this in the separate c3p0.properties file and specify which connection which property applies to. Answer to 'additional configuration properties' question requires to know the specifics of your environment. I would recommend looking at idle_test_period setting as these can typically have wrong defaults (make sure this matches relevant setting on the DB end).
A3: Yeah, this looks OK.
A4: You need to specify logging preferences in c3p0.properties or define them in dynamically as System properties. Refer to this chapter of the c3p0 manual.
A1: Yes
A2: Looks right at first glance. You need to be careful with RAC in case you would use distributed transactions - then I believe you would have to specify additional properties.
A3: Looks ok but depending on your task and estimated load I would play with maxIdleTime, acquireIncrement and maxPoolSize. For example with current settings after 60 seconds of inactivity your connection will be closed so next operation requesting connection after 60 seconds would incur penalty in waiting for new connection to open.
A4: http://www.mchange.com/projects/c3p0/index.html#configuring_logging
Advice:
There is a better connection pool from Tomcat 7, which could be used in Tomcat 6 as well. Consider it, especially if you need high performance
Consider connection testing so your application don't get (or get less frequently) exception when db connectivity goes down
It might be preferable to package connection pool and it's configuration within your application vs. in Tomcat. This way application WAR would be self contained so it could be just dropped into wabapps dir of tomcat.

Problems using db2 type 4 drivers with glassfish

I am trying to create a connection pool for a db2 database in glassfish and I'm somewhat new to the entire process. I created the pool yesterday with no problems, I pinged the server successfully and all was well. The next time I start glassfish, my connection pool is gone! After recreating the connection pool with the same settings, the ping is failing with the following error in the server.log:
RAR5099 : Wrong class name or classpath for Datasource Object java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2ConnectionPoolDataSource
I've tried moving the db2 driver .jar files around to lib/ or lib/ext/ and I've played around with the classpath prefixes and suffixes, but I've had no luck. It seems like glassfish isn't finding the drivers but I can't understand why.
BTW: I'm using OS X 10.6 and I configured the connection pool in a pretty basic way. I also added driverType = 4 to the properties.
Thanks in advance for your help!
You need to have the files db2jcc.jar and db2jcc_license_cu.jar in your classpath. The mentioned lib/ext/ should probably do the trick. The correct classname is probably com.ibm.db2.jcc.DB2SimpleDataSource for use with GlassFish.

WebSphere local transaction containment boundary issue J2CA0086W

In WebSphere, if you code opens two concurrent database connections, you get an error of the form:
J2CA0086W: Shareable connection MCWrapper id 556e556e Managed connection WSRdbManagedConnectionImpl#52365236 State:STATE_TRAN_WRAPPER_INUSE
from resource jdbc/abc was used within a local transaction containment boundary.
Our framework allows us to do so (nested transactions which can be on a separate connection or multiple named transactions). I've seen lots of references to turning off some switch in WebSphere to turn on connection sharing but no details on how to set this flag. Can someone point me to the steps to achieve this?
Specifically, if you see this article: http://www-01.ibm.com/support/docview.wss?rs=180&context=SSEQTP&dc=DB520&dc=D600&dc=DB530&dc=D700&dc=DB500&dc=DB540&dc=DB510&dc=DB550&q1=j2ca0086w&uid=swg21121449&loc=en_US&cs=utf-8&lang=en
under "Resolving the problem" I want to know how to set the connection pool to be unshareable (assuming that indeed solves the problem).
What version of IBM WAS are you using? If you have WAS 8, go to
Resources-> JDC-> Datasources-> your datasources -> WebSphere Application Server properties -> Datasources no transactional.
Sorry for my english.
The message happens when dataSource.getConnection() is called twice in
a servlet. The datasource jdbc/oracle is lookup from local reference.
Call it once and reuse the connection or call con.close() before doing the 2nd getConnection()

Resources