简体   繁体   English

在oracle weblogic Server中使用JDBC Pool,

[英]Using JDBC Pool in oracle weblogic Server,

I have a question that puzzles me these days. 这些天我有一个困扰我的问题。 I am using JDBC connection pool in oracle weblogc server for my REST API calls. 我在oracle weblogc服务器中使用JDBC连接池进行REST API调用。 The package was deployed and was able to handle the incoming requests correctly. 该软件包已部署,并且能够正确处理传入的请求。

But somehow, after a new request is made, in the db session level, I will get a new session row of "INACTIVE" status, even if I have purposely have the db connection closed in the code. 但是以某种方式,在发出新请求之后,在db会话级别中,即使我故意在代码中关闭了db连接,我也将获得一个新会话状态为“ INACTIVE”。 And seems to me, this session will kept for ever. 在我看来,本届会议将永远持续下去。 Eventually it kills the pool. 最终它杀死了游泳池。

Here is the sample of my code, where "apple" is my connection pool name. 这是我的代码示例,其中“ apple”是我的连接池名称。

    Connection connection = JDBCConnection.getJDBCConnction(apple);
    Statement stmt = null;
    String query ="select name from user";
    String hosts="";
    try {
        stmt = connection.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        while (rs.next()) {
            name   = rs.getString("name");
        }
    } finally {
        connection.close();
    }

Is there anything extra I need to do ? 我还有什么需要做的吗?

Thanks, 谢谢,

Jack 插口

You are likely running into an issue where you are closing the Connection but it does not result in closing the ResultSet or the Statement . 您可能会遇到关闭Connection的问题,但这不会导致ResultSetStatement关闭。

The topic has been explained extensively here and here on SO. 在SO的此处此处已对该主题进行了广泛的解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM