简体   繁体   English

如何调试oracle连接?

[英]How to debug oracle connection?

I'm using oracle database. 我正在使用oracle数据库。 Say I used a jdbc connection in my java web application deployed in a tomcat server running in eclipse, and I forget to close this connection in code after using it. 假设我在部署在Eclipse中运行的tomcat服务器中的Java Web应用程序中使用了jdbc连接,而忘记了使用该连接后在代码中关闭该连接。 Then, if I stop the tomcat server, will the connection be released and everything is OK, or it will cause some side effects in the oracle database, say some dead connections, and gradually cause the database down? 然后,如果我停止了tomcat服务器,连接将被释放并且一切正常,还是会在oracle数据库中引起一些副作用,例如某些无效连接,并逐渐导致数据库崩溃?

And how to debug this kind of problems? 以及如何调试此类问题? I mean are there any tools which can let me see the active(and 'dead', if any) connections in my database, and their client address, etc? 我的意思是,有没有什么工具可以让我查看数据库中的活动(和“死”(如果有的话)连接)及其客户端地址等?

You could setup Database Connection pooling in Tomcat's META-INF/context.xml file. 您可以在Tomcat的META-INF / context.xml文件中设置数据库连接池。 It can be setup so that abandoned database connections are removed and recycled. 可以进行设置,以便删除并回收废弃的数据库连接。

more info: 更多信息:

Apache Tomcat 7 JNDI Datasource HOW-TO Apache Tomcat 7 JNDI数据源HOW-TO

You can query Oracle's v$session and v$process to find out about connections, if they're locked, the name of the process that initiated the connection, the machine name and other info. 您可以查询Oracle的v $ session和v $ process来查找有关连接的信息(如果它们已被锁定),启动连接的进程的名称,计算机名和其他信息。

You can use this in your database 您可以在数据库中使用它

select * from v$session

and find dead session then 然后找到死会议

kill session 'sid,serial#' 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM