Search code examples
javawebsphere-8

Closing Native Connection Cause Warnings in Webpshere 8.5 Logs


I am getting struct descriptor with using Oracle types. There is no problem getting struct descriptor and creating oracle.sql.struct. I have use native connection to get struct descriptor. At the end i am trying to close the connection. Here some codes. The code runs on Websphere 8.5.5.4 and Websphere 8.5.5.7 application servers. The program runs correctly. But when i look to the webpshere logs i see some warnings. What i have to do with not seeing these warnings?

Notes: Our JDBC provider is connection pool.

[11/16/15 10:44:27:199 EET] 0000006f ConnectionEve W J2CA0206W: A connection error occurred. To help determine the problem, enable the Diagnose Connection Usage option on the Connection Factory or Data Source. This is the multithreaded access detection option. Alternatively check that the Database or MessageProvider is available. [11/16/15 10:44:27:200 EET] 0000006f ConnectionEve A J2CA0216I: The Connection Manager received a fatal connection error from the Resource Adapter for resource DSOra. Information may be available in previous messages or exceptions.

    Object[] baslikObj = new Object[12];
....
    Object[] detayObj = new Object[22];
....
    WebSphereNativeJdbcExtractor nje  = new WebSphereNativeJdbcExtractor();     
    Connection conn =  nje.getNativeConnection(dbUtil.getDataSource().getConnection());

     try {
        // Create descriptor
        StructDescriptor baslikDesc = StructDescriptor.createDescriptor(
                "SCHEMA1.A_TYPE", conn);
        StructDescriptor detayDesc = StructDescriptor.createDescriptor(
                "SCHEMA1.B_TYPE", conn);
        StructDescriptor temp1 = StructDescriptor.createDescriptor(
                "SCHEMA1.C_TYPE", conn);
        StructDescriptor temp2 = StructDescriptor.createDescriptor(
                "SCHEMA1.D_TYPE", conn);
        StructDescriptor temp3 = StructDescriptor.createDescriptor(
                "SCHEMA1.E_TYPE", conn);
        StructDescriptor temp4 = StructDescriptor.createDescriptor(
                "SCHEMA1.F_TYPE", conn);

        Object[] objdata1 = new Object[22];
        Object[] objdata2 = new Object[48];
        Object[] objdata3 = new Object[45];
        Object[] objdata4 = new Object[65];

        // Create oracle object parameter
        STRUCT baslik = new STRUCT(baslikDesc, conn, baslikObj);
        STRUCT detay = new STRUCT(detayDesc, conn, detayObj);
        STRUCT obj1 = new STRUCT(temp1, conn, objdata1);
        STRUCT obj2 = new STRUCT(temp2, conn, objdata2);
        STRUCT obj3 = new STRUCT(temp3, conn, objdata3);
        STRUCT obj4 = new STRUCT(temp4, conn, objdata4);
    } catch (Exception e) {
        throw e;
    } finally {
        conn.close();
    }

I try some tips that i found on the internet; 1) I enable Detecting MultiThreaded access to a connection on Websphere and i wait to see DSRA8720W message if it detects multi-threaded access to JDBC objects, bu nothing appears. 2) Then i open database trace in JVM with =info: com.ibm.ws.rsadapter.=all

[11/16/15 10:44:27:199 EET] 0000006f WSRdbManagedC 1   connectionClosed 
                             Notification of connection closed received from the JDBC driver. 
                             WSRdbManagedConnectionImpl@ba42247f 
                            oracle.jdbc.pool.OraclePooledConnection@d32085a1 
[11/16/15 10:44:27:199 EET] 0000006f WSManagedConn >  moveToNextFailoverServer Entry 
                             0 
[11/16/15 10:44:27:199 EET] 0000006f WSManagedConn <  moveToNextFailoverServer Exit 
                             <null> 
[11/16/15 10:44:27:199 EET] 0000006f WSJdbcConnect >  close Entry 
                             com.ibm.ws.rsadapter.jdbc.WSJdbcConnection@950c4377 
[11/16/15 10:44:27:199 EET] 0000006f WSJdbcConnect 1   state --> CLOSED 
[11/16/15 10:44:27:199 EET] 0000006f WSJdbcConnect 3   doConnectionCleanupPerCloseConnection on [helper, mc, sqlCon, returned value] 
                             com.ibm.websphere.rsadapter.Oracle11gDataStoreHelper@b8472e1f 
                             WSRdbManagedConnectionImpl@ba42247f 
                             oracle.jdbc.driver.LogicalConnection@51b3cf57 
                             false 
[11/16/15 10:44:27:199 EET] 0000006f WSJdbcConnect <  close Exit 
[11/16/15 10:44:27:199 EET] 0000006f WSRdbManagedC 1   Firing CONNECTION_ERROR_OCCURRED  event for handle: null 
                             WSRdbManagedConnectionImpl@ba42247f 
[11/16/15 10:44:27:199 EET] 0000006f ConnectionEve W   J2CA0206W: A connection error occurred.  To help determine the problem, enable the Diagnose Connection Usage option on the Connection Factory or Data Source. This is the multithreaded access detection option. Alternatively check that the Database or MessageProvider is available. 
 [11/16/15 10:44:27:200 EET] 0000006f ConnectionEve A   J2CA0216I: The Connection Manager received a fatal connection error from the Resource Adapter for resource takasDSOra. Information may be available in previous messages or exceptions. 
 [11/16/15 10:44:27:201 EET] 0000006f WSRdbManagedC >  dissociateConnections Entry 
                             WSRdbManagedConnectionImpl@964b988c 
 [11/16/15 10:44:27:201 EET] 0000006f WSRdbManagedC <  dissociateConnections Exit 
 [11/16/15 10:44:27:201 EET] 0000006f WSRdbManagedC >  cleanup Entry 
                             WSRdbManagedConnectionImpl@964b988c 
 [11/16/15 10:44:27:201 EET] 0000006f OracleUtility >  closeProxySession Entry 
 [11/16/15 10:44:27:201 EET] 0000006f OracleUtility <  closeProxySession Exit 
                             false 
 [11/16/15 10:44:27:201 EET] 0000006f WSManagedConn >  getPurgePolicy Entry 
 [11/16/15 10:44:27:201 EET] 0000006f WSManagedConn <  getPurgePolicy Exit 
                             EntirePool 
 [11/16/15 10:44:27:201 EET] 0000006f WSRdbManagedC <  cleanup Exit 
 [11/16/15 10:44:27:201 EET] 0000006f WSRdbManagedC >  removeConnectionEventListener Entry 
                             com.ibm.ejs.j2c.ConnectionEventListener@6d070d81 
 [11/16/15 10:44:27:201 EET] 0000006f WSRdbManagedC <  removeConnectionEventListener Exit 
[11/16/15 10:44:27:201 EET] 0000006f WSRdbManagedC >  destroy Entry 
                             WSRdbManagedConnectionImpl@964b988c

Also I found this on the ibm support and it says “Do not actually close the underlying physical connection; instead, close the connection handle from the application server. If you close the native connection handle, there will be failures the next time the application server uses the connection handle.” But i dont know what i have to do with the open native connection.


Solution

  • After i change the code below, warnings are disappeared. When i close the actual connection the underlying connection is closed too. After close the actual connection, if you control both connection with isClosed, they return true.

    WebSphereNativeJdbcExtractor nje = new WebSphereNativeJdbcExtractor();
    Connection connect = dbUtil.getDataSource().getConnection();
    Connection conn =  nje.getNativeConnection(connect);
    
    try {
      ...
    } catch (Exception e) {
        throw e;
    } finally {
        connect.close();
    }