Domanda

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.

È stato utile?

Soluzione

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.

<validation>
    <check-valid-connection-sql>select 1</check-valid-connection-sql>
<validation>

The above was incorrect and DB2 was giving a validation error.

I changed that to the following instead:

      <validation>
          <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ValidConnectionChecker"/>
          <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2StaleConnectionChecker"/>
          <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ExceptionSorter"/>
      </validation>

Here is the complete datasource set up in case anybody else finds it useful.

    <datasource jndi-name="java:jboss/datasources/DB2_zOS_DS" pool-name="DB2_zOS_DS" enabled="true" use-java-context="true">
      <connection-url>jdbc:db2://MyHostName:MyPortNo/MyDBQA1:currentSchema=MySchemaQA1;</connection-url>
      <driver>db2zOS</driver>
      <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
      <pool>
          <min-pool-size>9</min-pool-size>
          <max-pool-size>50</max-pool-size>
          <prefill>true</prefill>
          <allow-multiple-users/>
      </pool>
      <security>
          <user-name>MY-APP-ID</user-name>
          <password>My-APP-ID-PASSWORD</password>
      </security>
      <validation>
          <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ValidConnectionChecker"/>
          <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2StaleConnectionChecker"/>
          <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ExceptionSorter"/>
      </validation>
      <timeout>
          <set-tx-query-timeout>true</set-tx-query-timeout>
          <blocking-timeout-millis>500</blocking-timeout-millis>
          <idle-timeout-minutes>15</idle-timeout-minutes>
      </timeout>
      <statement>
          <track-statements>false</track-statements>
          <prepared-statement-cache-size>32</prepared-statement-cache-size>
          <share-prepared-statements>true</share-prepared-statements>
      </statement>
    </datasource>
    <drivers>
      <driver name="db2zOS" module="com.ibm.db2">
          <driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
      </driver>
    </drivers>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top