首页 文章

即使在connection.close()调用之后,连接也处于已 Build 状态

提问于
浏览
0

我正在编写代码来使用cloudera提供的JDBC驱动程序访问impala . 而且效果很好 .

但是,我面临一个小问题,...

关闭连接后,当我使用netstat -an |检查连接时grep -i 21050,我得到的连接仍处于Established状态,直到程序退出,程序退出时清除所有Established连接 .

Connection con = DriverManager.getConnection(“jdbc:impala://10.184.43.100:21050”); con.close(); ///连接应该在这里关闭 . 但它不在这里关闭Thread.sleep(20000); ///连接正在关闭

Why connections to impalad are still alive even after calling the connection.close(). ???? Am i doing something wrong???

要模拟这个,请检查以下代码,之后的位置

public class ClouderaJDBCImpalaExample {
// Define a string as the fully qualified class name (FQCN) of
// the desired JDBC driver
static String JDBCDriver = "com.cloudera.impala.jdbc41.Driver";
// Define a string as the connection URL
static String ConnectionURL = "jdbc:impala://10.184.43.100:21050";

static{
        try {
            // Register the driver using the class name
            Class.forName(JDBCDriver);
            LogController.logInfoMessage("Impala Driver Loaded.");
        }catch(Exception ex)
        {
            ex.printStackTrace();
            System.exit(0);
        }
    }
public static void main(String[] args) throws InterruptedException {

 Connection con =   DriverManager.getConnection("jdbc:impala://10.184.43.100:21050");
        con.close();
        ///The connection should close here. But its not closing here
        Thread.sleep(20000);
       ///Connection is closing here.
}

root @ pasapp~#netstat -an | grep -i 21050

tcp 0 0 0.0.0.0:21050 0.0.0.0:* LISTEN
tcp 0 0 10.184.43.100:21050 169.144.48.135:52137已 Build
root @ pasapp~#

谢谢 !!!

1 回答

  • 1

    此驱动程序执行连接池 . 你的关闭!=游泳池的关闭 . 毫无疑问,有一些方法可以配置池 .

相关问题