Quantcast
Channel: Teradata Downloads - Connectivity
Viewing all articles
Browse latest Browse all 445

dead connection from jdbc pool for the first time run

$
0
0

Hi,
we have a jdbc data source configured in sap netweaver java server,which connects to Teradata(13.10.07.28). the jdbc driver version is 15.00.00.20.
we have an ejb consuming that data source.
the java server is running on windows.

private Connection getConnection() throws SQLException {
		Connection conn = _dataSource.getConnection();
		for (int i = 0; i < 3; i++) {

			try {
				if (!conn.isValid(30)) {
					conn = _dataSource.getConnection();
					Statement st=conn.createStatement();// this line throws the error
					st.close();
					st=null;
				} else {
					_location.infoT("get the connection at "+i+" try.");
					break;
				}
			} catch (Exception e) {
				_location.traceThrowableT(Severity.ERROR, "", e);
			}

		}

		return conn;
	}

the problem is this methd always return me the dead connection if it is the first time to run the code. it gives valid connection if you run it immediately after the failure and afterwards. if you haven't accessed it for a while, you will get the issue if u run it again and you get valid connection if u run it after the failuer.
in my code  i am checking the connection is dead or live, but it doesn't help.
If you write following code, the loop never ends until server restart(because of out of memory) for the first time run.

While(!conn.isValid(30)){

conn = _dataSource.getConnection();

}
[EXCEPTION]
 java.sql.SQLException: [Teradata JDBC Driver] [TeraJDBC 15.00.00.20] [Error 1095] [SQLState HY000] Cannot call a method on closed connection 
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:94) 
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:64) 
at com.teradata.jdbc.jdbc_4.TDSession.createStatement(TDSession.java:1339) 
at com.teradata.jdbc.jdbc_4.TDSession.createStatement(TDSession.java:645) 
at com.teradata.jdbc.jdbc_4.TDSession.createStatement(TDSession.java:1380) 
at com.sap.sql.jdbc.vendor.VendorConnectionHandle.createStatement(VendorConnectionHandle.java:79) 
at com.sap.engine.services.dbpool.cci.ConnectionHandle.createStatement(ConnectionHandle.java:97) 

any advice will be appreciated.
Thanks
Jun

Forums: 

Viewing all articles
Browse latest Browse all 445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>