My java app deployed in jboss AS 7, queries a MS SQL server database using spring data. I also need to call a DB2 function on zOS for which I use Spring JdbcTemplate. The SQL is:
public String getUniqueId()
{
String sql = "SELECT " + schemaName + ".SGB_LON_ID_NEXT() FROM SYSIBM.SYSDUMMY1" ;
return (jdbcTemplate.queryForLong(sql));
}
Unit tests in Eclipse work fine. When I deploy in the jboss server, the first call works. However, the second transaction onwards, the call itself works, but a few warnings appear in the server.log for each call.
I wonder if it could be the fact that the JDBC call is NOT a part of the JPA transaction. (note that the jdbc call is a simple - the DB2 function just returns the next serial number for a field )
Here are the warning messages from the error stack:
21:50:33,955 WARN [org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory] (http-/127.0.0.1:8080-14)
Destroying connection that is not valid, due to the following exception: com.ibm.db2.jcc.t4.b@1167bd5: com.ibm.db2.jcc.am.SqlSyntaxErrorException:
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=<END-OF-STATEMENT>;MICROSECONDS MICROSECOND SECONDS SECOND MINUTES MIN, DRIVER=3.63.123
21:50:34,096 WARN [org.jboss.jca.core.connectionmanager.listener.TxConnectionListener] (http-/127.0.0.1:8080-14)
IJ000305: Connection error occured:org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@f79f0f[state=NORMAL managed connection=org.jboss.jca.adapters.jdbc.local.LocalManagedConnection@136e43e connection handles=0 lastUse=1359255001136 trackByTx=false
pool=org.jboss.jca.core.connectionmanager.pool.strategy.PoolByCri@c2c2de pool internal context=SemaphoreArrayListManagedConnectionPool@8793c7[pool=DB2_zOS_DS]
xaResource=LocalXAResourceImpl@f70194[connectionListener=f79f0f connectionManager=112dadb warned=false currentXid=null] txSync=null]:
com.ibm.db2.jcc.am.SqlSyntaxErrorException:
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=<END-OF-STATEMENT>;MICROSECONDS MICROSECOND SECONDS SECOND MINUTES MIN, DRIVER=3.63.123
21:50:34,196 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.PoolByCri] (http-/127.0.0.1:8080-14)
IJ000612: Destroying connection that could not be successfully matched: org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@f79f0f[state=DESTROYED managed connection=
org.jboss.jca.adapters.jdbc.local.LocalManagedConnection@136e43e connection handles=0 lastUse=1359255001136 trackByTx=false
pool=org.jboss.jca.core.connectionmanager.pool.strategy.PoolByCri@c2c2de pool internal context=SemaphoreArrayListManagedConnectionPool@8793c7[pool=DB2_zOS_DS]
xaResource=LocalXAResourceImpl@f70194[connectionListener=f79f0f connectionManager=112dadb warned=false currentXid=null] txSync=null]
Any suggestions on how to fix? I am not clear on how to add the JDBC call to the current transaction (JPA). Or should it be a separate transaction. As stated earlier the jdbc call is a db2 function that returns the next value for a sequence number.
The problem turned out to be in my datasource setup in JBOSS_HOME/standalone/configuration/standalone.xml.
In the validation section, I had this which was incorrect.
The above was incorrect and DB2 was giving a validation error.
I changed that to the following instead:
Here is the complete datasource set up in case anybody else finds it useful.