Database Connection Validation Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting database connection pool java example ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join
Database Connection Pool Implementation In Java
the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a tomcat database connection pool minute: Sign up What is a validationQuery with respect to databases and JNDI? up vote 2 down vote favorite I seem to be having the same exact problem as the poster of this original SO question. The problem is, he answered http://www.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/tdat_connectimeout.html his own question with the following comment: I solved my problem, I added a validationQuery to my JNDI datasource. Unfortunately, that doesn't mean anything to me, and doesn't help me solve my problem. So I ask: what is a "validationQuery" with respect to my database (Sybase) and the JNDI entry used to hold the server lookup info? Thanks in advance. java jdbc database-connection sybase jndi share|improve this question asked Mar 13 '13 at 18:51 IAmYourFaja 6,72188288550 Is this sybase-asa, sybase-ase, http://stackoverflow.com/questions/15393954/what-is-a-validationquery-with-respect-to-databases-and-jndi sybase-iq, or sqlanywhere? Trying to clean up the sybase tag... –Danny Beckett Mar 15 '13 at 7:45 add a comment| 3 Answers 3 active oldest votes up vote 5 down vote accepted The validation query is a query run by the data source to validate that a Connection is still open before returning it. Here's Tomcat's definition of a validation query; scroll down to the middle of section "4. Configure Tomcat's Resource Factory", looking for the "validationQuery" attribute. EDIT According to this answer, if the validation query fails, no error is thrown; the bad/closed connection is dropped and another connection is created to replace it. share|improve this answer edited Mar 13 '13 at 19:26 answered Mar 13 '13 at 19:09 rgettman 121k15138227 Thanks @rgettman (+1) - so it's a query that I configure Sybase (the data source) to run prior to returning a connection. I assume it throws an exception that I can catch, or returns some error-value that I can use on the app-side to determine that a connection isn't available, and that I need to try again? Thanks again! –IAmYourFaja Mar 13 '13 at 19:16 And another thing: that article doesn't explain what happens when a connection isn't available? Throws an error? –IAmYourFaja Mar 13 '13 at 19:24 I've edited my answer. –rgettman Mar 13 '13 at 19:26 add a comment| up vote 1 down vote I assume it is a query to test if DB connection
Connectionat oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146) https://confluence.atlassian.com/confkb/handling-oracle-database-connection-pool-closed-connection-errors-224395458.html at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208) at oracle.jdbc.driver.PhysicalConnection.rollback(PhysicalConnection.java:1170) at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.rollback(DelegatingConnection.java:368) at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.rollback(PoolingDataSource.java:323) at net.sf.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:86) at org.springframework.orm.hibernate.HibernateTransactionManager.doRollback(HibernateTransactionManager.java:529) https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Administration_and_Configuration_Guide/sect-Database_Connection_Validation.html at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:753) at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:730) at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.j Cause External devices such as firewall, network devices, database connection and remote database listeners can force network connections to close after a period of inactivity. The database connection pool (DPCP) or C3PO (if using direct JDBC) is not able to detect when the network database connection pool connection has been terminated. It is only when Confluence attempts to use a connection from the pool that a 'Closed Connection' exception is raised. Resolution Refer to the document Surviving Connection Closures to add in validation queries for your database. This will allow the datasource connection to run a validation query against the database before usage to verify the connection is usable. Add an additional connection property: 'oracle.net.READ_TIMEOUT=5000' for jdbc versions< 10.1.0.5 or 'oracle.jdbc.ReadTimeout=5000' for jdbc versions>=10.1.0.5 to the resource definition. The following is for Oracle databases only: events may cause JBoss EAP 6 to lose the connection to the database. You enable database connection validation using the