如何防止 Oracle SQL Developer 关闭数据库连接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1309254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 02:06:20  来源:igfitidea点击:

How can I keep Oracle SQL Developer from closing the DB connection?

oracleoracle10goracle-sqldeveloper

提问by Kevin Babcock

Is there any way to keep Oracle SQL Developer from closing my DB connections, or to increase the timeout? Sometimes during a long-running query SQL Dev will just close the connection, leaving my query running on the server but me with no results. If I RDP into the server and run SQL Dev locally it never seems to have this problem.

有什么办法可以阻止 Oracle SQL Developer 关闭我的数据库连接,或者增加超时时间?有时在长时间运行的查询中,SQL Dev 会关闭连接,让我的查询在服务器上运行,但我没有结果。如果我 RDP 进入服务器并在本地运行 SQL Dev,它似乎永远不会有这个问题。

采纳答案by Matthew Watson

This doesn't sound like an issue with SQL developer, cetainly I've never come across it. Are you sure it's not something else, like your network? What happens if you connect from SQL plus from your desktop.

这听起来不像是 SQL 开发人员的问题,当然我从来没有遇到过。你确定它不是别的东西,比如你的网络?如果从桌面连接 SQL plus 会发生什么。

回答by DelGurth

I don't have the answer for this, but I'm experiencing the same problem.

我没有答案,但我遇到了同样的问题。

The firewall between my SQL Developer and the database automaticly closes "inactive" sessions. A long running query is according to the firewall an inactive session, so he closes it. I've not, yet, found how to make SQL Developer send packets over a connection with a long running query, so that the firewall doesn't close the connection. And I don't know if this is possible at all.

我的 SQL Developer 和数据库之间的防火墙会自动关闭“非活动”会话。根据防火墙,长时间运行的查询是一个非活动会话,因此他将其关闭。我还没有找到如何让 SQL Developer 通过具有长时间运行的查询的连接发送数据包,以便防火墙不会关闭连接。我不知道这是否可能。

So I don't think it is a SQL Developer problem, but a firewall issue.

所以我不认为这是 SQL Developer 的问题,而是防火墙问题。

-- UPDATE

- 更新

There is an extension for SQL Developer that allows you to keep the connections active: http://sites.google.com/site/keepaliveext/

SQL Developer 有一个扩展,允许您保持连接处于活动状态:http: //sites.google.com/site/keepaliveext/

It's not totally finished yet (for example the notification you get states the same timeout no matter what timeout you have specified) but it does the trick. I've not, yet, tested it against the latest SQL Developer pre-release, but it worked with SQL Developer 2.2.x

它还没有完全完成(例如,无论您指定什么超时,您收到的通知都会声明相同的超时)但它确实有效。我还没有针对最新的 SQL Developer 预发行版对其进行测试,但它适用于 SQL Developer 2.2.x

-- UPDATE

- 更新

For SQL Developer 4+ you can use: http://scristalli.github.io/SQL-Developer-4-keepalive/

对于 SQL Developer 4+,您可以使用:http: //scristalli.github.io/SQL-Developer-4-keepalive/

回答by Dr.7

Here's another Keep Connection Active extension that might be of use. (The extension mentioned above contains a number of issues that are resolved in this extn.)

这是另一个可能有用的 Keep Connection Active 扩展。(上面提到的扩展包含许多在此扩展中解决的问题。)

http://sites.google.com/site/keepconnext/

http://sites.google.com/site/keepconnext/

回答by David Mann

Also sounds like a firewall problem to me.

对我来说也听起来像是防火墙问题。

You may have some luck with setting EXPIRE_TIME parameter in the server's SQLNET.ORA file. From the documentation:

在服务器的 SQLNET.ORA 文件中设置 EXPIRE_TIME 参数可能会有些运气。从文档:

Use parameter SQLNET.EXPIRE_TIME to specify a the time interval, in minutes, to send a probe to verify that client/server connections are active. Setting a value greater than 0 ensures that connections are not left open indefinitely, due to an abnormal client termination. If the probe finds a terminated connection, or a connection that is no longer in use, it returns an error, causing the server process to exit. This parameter is primarily intended for the database server, which typically handles multiple connections at any one time.

使用参数 SQLNET.EXPIRE_TIME 指定时间间隔(以分钟为单位),以发送探测以验证客户端/服务器连接是否处于活动状态。设置一个大于 0 的值可确保连接不会因客户端异常终止而无限期地打开。如果探测器发现一个终止的连接,或者一个不再使用的连接,它会返回一个错误,导致服务器进程退出。此参数主要用于数据库服务器,它通常一次处理多个连接。

10g Documentation on EXPIRE_TIME

EXPIRE_TIME 上的 10g 文档

回答by Vineet

As a temporary solution to it, at the side of 'Data Grid' you'll find the tab 'DBMS Output', turn DBMS output ON and set the polling frequency to an agreeable time.

作为临时解决方案,在“数据网格”的一侧,您将找到“DBMS 输出”选项卡,打开 DBMS 输出并将轮询频率设置为合适的时间。

回答by Thomas

our DBA seems to have found a solution to this:

我们的 DBA 似乎已经找到了解决方案:

2.2. If there is a firewall present between the OC4J instance & the Database The firewall might drop inactive jdbc connections to the database server. However, the OC4J instance cannot detect that the firewall has timed out the connection to the database. Oracle Net can be configured with Dead Connection Detection (SQLNET.EXPIRE_TIME) to workaround this problem. Set EXPIRE_TIME on the database server to a value less than the firewall connection timeout so that DCD keeps the connection to the database alive. See Note 151972.1 "Dead Connection Detection (DCD) Explained". Since this is a setting configured on the database server, not on the midtier, it will apply for all database connections (OCI and thin JDBC). Alternative solutions: - Disable or increase the idle timeout parameter of the firewall. or - Configure the TCP Keepalive time setting on the database and on midtier servers to a value less than the firewall connection timeout. After setting the TCP Keepalive time, the machines will send repeatedly a null packet after the minutes specified to keep the connections alive. As the packet is sent every time inside the firewall idle timeout, the connection will not get closed.

2.2. 如果 OC4J 实例与数据库之间存在防火墙 防火墙可能会断开与数据库服务器的非活动 jdbc 连接。但是,OC4J 实例无法检测到防火墙已超时与数据库的连接。可以使用死连接检测 (SQLNET.EXPIRE_TIME) 配置 Oracle Net 来解决此问题。将数据库服务器上的 EXPIRE_TIME 设置为小于防火墙连接超时的值,以便 DCD 保持与数据库的连接处于活动状态。请参见注释 151972.1“死连接检测 (DCD) 说明”。由于这是在数据库服务器上而不是在中间层上配置的设置,因此它将适用于所有数据库连接(OCI 和瘦 JDBC)。替代解决方案: - 禁用或增加防火墙的空闲超时参数。或 - 将数据库和中间层服务器上的 TCP Keepalive 时间设置配置为小于防火墙连接超时的值。设置 TCP Keepalive 时间后,机器将在指定的分钟后重复发送一个空数据包以保持连接活动。由于每次在防火墙空闲超时内发送数据包,因此连接不会关闭。

回答by PiC

#1. Check with th3 DBA what is the user's profile of the used connecting. Then check inactivity timeouts for the profile.

#1. 与 th3 DBA 检查所用连接的用户配置文件是什么。然后检查配置文件的不活动超时。

#2. Change the connection setting in SQL Developer to Connection Type=Basic and use SID (not Service Name).

#2. 将 SQL Developer 中的连接设置更改为 Connection Type=Basic 并使用 SID(而不是服务名称)。

Connection Properties in SQL Developer

SQL Developer 中的连接属性

If you use Connection Type=TNSNAMES or Service Name instead of SID - the connections will be dropped.

如果您使用 Connection Type=TNSNAMES 或 Service Name 而不是 SID - 连接将被丢弃。