【发布时间】:2010-09-27 14:23:33
【问题描述】:
我正在使用 Eclipse 开发一个 java web 应用程序,我的 IT 部门打电话说我有超过 75 个开放的 oracle 连接到来自我的 PC 的开发 Oracle 服务器。部署的应用程序已经使用同一个单例连接 bean 一年了,我没有遇到任何超出连接的问题。 IT 甚至确认我在部署服务器上只有 4 个打开的连接。当我在 Eclipse 中进行本地开发时,发生了一些事情。
查看控制台调试输出,初始启动时一切正常
Sep 27, 2010 9:39:08 AM org.apache.catalina.startup.Catalina start
== no ConnCache Bean instance found
== Initializing Connection Cache Data Src
== About to load the properties
== Initializing Datasource for using jdbc:oracle:thin:@hostname:port:oracle-sid
== Reading property file
== Setting InitialLimit to 3
== Properties {TimeToLiveTimeout=4, MinLimit=4, ConnectionWaitTimeout=44, MaxLimit=5, InitialLimit=3, AbandonedConnectionTimeout=281, InactivityTimeout=269}
但是当 Eclipse 重新加载上下文时,我在控制台中注意到以下 SEVERE 消息
Sep 27, 2010 9:40:38 AM org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
Sep 27, 2010 9:40:38 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [] registered the JBDC driver [oracle.jdbc.driver.OracleDriver] but failed to unregister
it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Sep 27, 2010 9:40:38 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [Thread-9] but has failed to stop it.
This is very likely to create a memory leak.
我猜测 Eclipse 每次重新加载上下文时都会重新创建连接缓存,并且旧的连接和缓存不会被破坏。重新加载上下文时,如何让 Eclipse 终止缓存或关闭所有先前的连接。如有必要,我可以发布我的 connectionBean 类。
【问题讨论】:
-
勇敢的人!在生产服务器上开发。编辑,对不起,这不是那么有帮助。在我的正常设置(eclipse、tomcat)中,我运行了一个本地版本的 tomcat,它可以重新启动,从而刷新连接池。我不知道这在您的设置中是否可行。
-
@Jaydee,我正在本地开发。我们有一个开发、阶段和生产 Web 服务器以及一个开发、阶段和生产 Oracle 服务器。 Eclipse IDE 上的本地开发使用本地 apache 安装,但连接到 Dev Oracle 服务器。部署的应用程序位于生产网络服务器上,并连接到生产 Oracle 服务器。
-
对不起,我假设了很多,并且不合时宜。 Vineet 的回答看起来值得一试。
-
不用担心,我编辑了我的帖子以澄清它是针对开发 oracle 服务器的。真的没有理由在我的 PC 上拥有 db 的第 4 个副本。
标签: java eclipse connection