[英]Connection is in established state even after connection.close() call
I am writing code to access impala using JDBC driver provided by the cloudera . 我正在编写代码,以使用cloudera提供的JDBC驱动程序访问impala。 And it works perfectly .
而且效果很好。
But , I am facing a small problem,.. 但是,我面临一个小问题。
After closing a connection , when i am checking the connections using netstat -an | 关闭连接后,当我使用netstat -an |检查连接时 grep -i 21050 , I am getting connections are still in Established state until the program exits, when program exits it clears all the Established connections.
grep -i 21050,直到程序退出之前,我一直处于连接状态,当程序退出时,它会清除所有已建立的连接。
Connection con =
连接con =
DriverManager.getConnection("jdbc:impala://10.184.43.100:21050");DriverManager.getConnection(“ jdbc:impala://10.184.43.100:21050”);
con.close();
con.close();
///The connection should close here.
///连接应在此处关闭。 But its not closing here
但它没有在这里关闭
Thread.sleep(20000);
线程。睡眠(20000);
///Connection is closing here.
///连接在这里关闭。
Why connections to impalad are still alive even after calling the connection.close(). 为什么即使调用connection.close()后,与impalad的连接仍然有效。 ????
???? Am i doing something wrong???
难道我做错了什么???
To simulate this please check the below code , where after 为了模拟这一点,请检查以下代码,之后
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 |
root @ pasapp〜#netstat -an | grep -i 21050
grep -i 21050
tcp 0 0 0.0.0.0:21050 0.0.0.0:* LISTEN 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 ESTABLISHED tcp 0 0 10.184.43.100:21050 169.144.48.135:52137已建立
root@pasapp ~ # root @ pasapp〜#
Thanks !!! 谢谢 !!!
This driver does connection pooling. 该驱动程序进行连接池。 Your close != the pool's close.
您的关闭!=游泳池关闭。 No doubt there is some way to configure the pool.
毫无疑问,有一些方法可以配置池。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.