connection仍处于已建立状态

ecr0jaav  于 2021-06-26  发布在  Impala
关注(0)|答案(1)|浏览(327)

我正在编写代码,使用cloudera提供的jdbc驱动程序访问impala。而且效果很好。
但是,我面临一个小问题,。。
关闭连接后,当我使用netstat-an | grep-i21050检查连接时,我得到的连接仍然处于已建立状态,直到程序退出,当程序退出时,它清除所有已建立的连接。
连接con=
drivermanager.getconnection(“jdbc:impala://10.184.43.100:21050");
con.close();
///连接应该在这里关闭。但这里还没关门
睡眠(20000);
///连接正在关闭。
为什么调用connection.close()后到impalad的连接仍然有效????我做错什么了吗???
要模拟这一点,请检查下面的代码,其中

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

zed5wv10

zed5wv101#

此驱动程序执行连接池。你的接近!=游泳池就在附近。毫无疑问,有一些方法可以配置池。

相关问题