即使在 connection.close() 调用后连接仍处于已建立状态

Connection is in established state even after connection.close() call

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

但是,我遇到了一个小问题,..

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

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.

为什么到 impalad 的连接在调用 connection.close() 之后仍然存在。 ???我做错了什么吗???

要模拟这个,请检查下面的代码,在

之后
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:* 听
tcp 0 0 10.184.43.100:21050 169.144.48.135:52137 已建立
root@pasapp ~ #

谢谢!!!

此驱动程序执行连接池。你的收盘价!= 池的收盘价。毫无疑问,有一些方法可以配置池。