关闭本机连接会导致 Websphere 8.5 日志中出现警告
Closing Native Connection Cause Warnings in Webpshere 8.5 Logs
我正在使用 Oracle 类型获取结构描述符。获取结构描述符和创建 oracle.sql.struct 没有问题。我已经使用本机连接来获取结构描述符。最后我试图关闭连接。这里有一些代码。代码在 Websphere 8.5.5.4 和 Websphere 8.5.5.7 应用程序服务器上运行。程序运行正确。但是当我查看 webpshere 日志时,我看到了一些警告。我没有看到这些警告怎么办?
注意:我们的 JDBC 提供程序是连接池。
[11/16/15 10:44:27:199 EET] 0000006f ConnectionEve W J2CA0206W:发生连接错误。为帮助确定问题,请在连接工厂或数据源上启用诊断连接使用选项。这是多线程访问检测选项。或者检查数据库或 MessageProvider 是否可用。
[11/16/15 10:44:27:200 EET] 0000006f ConnectionEve A J2CA0216I:连接管理器从资源适配器接收到资源 DSOra 的致命连接错误。信息可能在以前的消息或异常中可用。
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();
}
我尝试了一些在互联网上找到的技巧;
1) 我在 Websphere 上启用了检测对连接的多线程访问,如果它检测到对 JDBC 对象的多线程访问,我会等待看到 DSRA8720W 消息,但是什么也没有出现。
2) 然后我使用 =info: com.ibm.ws.rsadapter.=all
在 JVM 中打开数据库跟踪
[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
我也在 ibm 支持上找到了这个,它说
“不要真正关闭底层的物理连接;相反,关闭来自应用程序服务器的连接句柄。如果关闭本机连接句柄,下次应用服务器使用连接句柄时就会失败。”
但我不知道我与开放的本机连接有什么关系。
我更改下面的代码后,警告消失了。当我关闭实际连接时,底层连接也将关闭。关闭实际连接后,如果您用 isClosed
控制两个连接,它们 return 为真。
WebSphereNativeJdbcExtractor nje = new WebSphereNativeJdbcExtractor();
Connection connect = dbUtil.getDataSource().getConnection();
Connection conn = nje.getNativeConnection(connect);
try {
...
} catch (Exception e) {
throw e;
} finally {
connect.close();
}
我正在使用 Oracle 类型获取结构描述符。获取结构描述符和创建 oracle.sql.struct 没有问题。我已经使用本机连接来获取结构描述符。最后我试图关闭连接。这里有一些代码。代码在 Websphere 8.5.5.4 和 Websphere 8.5.5.7 应用程序服务器上运行。程序运行正确。但是当我查看 webpshere 日志时,我看到了一些警告。我没有看到这些警告怎么办?
注意:我们的 JDBC 提供程序是连接池。
[11/16/15 10:44:27:199 EET] 0000006f ConnectionEve W J2CA0206W:发生连接错误。为帮助确定问题,请在连接工厂或数据源上启用诊断连接使用选项。这是多线程访问检测选项。或者检查数据库或 MessageProvider 是否可用。 [11/16/15 10:44:27:200 EET] 0000006f ConnectionEve A J2CA0216I:连接管理器从资源适配器接收到资源 DSOra 的致命连接错误。信息可能在以前的消息或异常中可用。
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();
}
我尝试了一些在互联网上找到的技巧; 1) 我在 Websphere 上启用了检测对连接的多线程访问,如果它检测到对 JDBC 对象的多线程访问,我会等待看到 DSRA8720W 消息,但是什么也没有出现。 2) 然后我使用 =info: com.ibm.ws.rsadapter.=all
在 JVM 中打开数据库跟踪[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
我也在 ibm 支持上找到了这个,它说 “不要真正关闭底层的物理连接;相反,关闭来自应用程序服务器的连接句柄。如果关闭本机连接句柄,下次应用服务器使用连接句柄时就会失败。” 但我不知道我与开放的本机连接有什么关系。
我更改下面的代码后,警告消失了。当我关闭实际连接时,底层连接也将关闭。关闭实际连接后,如果您用 isClosed
控制两个连接,它们 return 为真。
WebSphereNativeJdbcExtractor nje = new WebSphereNativeJdbcExtractor();
Connection connect = dbUtil.getDataSource().getConnection();
Connection conn = nje.getNativeConnection(connect);
try {
...
} catch (Exception e) {
throw e;
} finally {
connect.close();
}