如果我们关闭JVM,sql连接会自动关闭吗? [英] Will the sql connections automatically get closed if we close the JVM?

查看:365
本文介绍了如果我们关闭JVM,sql连接会自动关闭吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个创建20个线程的测试程序,然后这些线程将打开很多sql连接。让我们说你是从eclipse执行这个程序,现在如果你将关闭eclipse。这会关闭所有打开的sql连接吗?如果不是,那么会发生什么呢?它会在数据库端显示100个打开的连接吗?如果是,则在这种情况下做什么?

I created a test program which creates 20 threads and then these threads will open many sql connection. Lets say you are executing this program from eclipse and now if you will close eclipse. Will this close all opened sql connections? If not then what will happen to these? Will it show 100 opened connections on database side? If yes then what to do in this case?

推荐答案

连接不会像调用 java.sql.Connection.close()。基本上,打开连接的JVM无法保持到数据库的TCP / IP连接活动。这些将立即关闭。因此,连接也将被关闭。然而,数据库可能不会立即对此反应并保持其会话一段时间。

The connections won't close as in calling java.sql.Connection.close(). Basically, the JVM that opened the connection can not keep the TCP/IP connections to the database alive. These will be shut down immediately. Hence, the "connection" will be shut down as well. The database, however, may not react immediately to this and keep its sessions alive for a while.

在Oracle中,您可以直接杀死数据库中的会话,如果有足够的权限。

In Oracle, you can kill the sessions in the database directly, if you have sufficient privileges.

我猜,行为是特定于供应商和/或配置的。没有一般答案。

I guess, the behaviour is vendor-specific and/or configuration-specific. There is no general answer.

这篇关于如果我们关闭JVM,sql连接会自动关闭吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆