通过JDBC在Oracle中进行的非活动会话 [英] Inactive session in Oracle by JDBC

查看:303
本文介绍了通过JDBC在Oracle中进行的非活动会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个用Java编写的Web服务,并且正在连接到Oracle数据库以进行数据提取.最近,我们的Web服务JDBC在Oracle数据库中遇到了太多的非活动会话.

We have a web service written in Java and is connecting to Oracle database for data extraction. Recently, we encountered too many inactive session in Oracle database from JDBC which is our web service.

我们非常确定所有连接都已关闭,并且在每个进程之后都设置为null.

We are very sure that all the connection is being closed and set to null after every process.

有人可以帮助我们吗?为什么会导致数据库中的非活动会话,以及对此的解决方案是什么?

Can anyone help us in this? Why is it causing inactive session in the database and what can be the solution to this.

谢谢.

推荐答案

究竟是什么问题?

通常,中间层应用程序服务器创建一个连接池.当您的代码请求连接时,它会从池中获得一个已打开的连接,而不会产生产生与数据库的新连接的开销.当您的代码关闭连接时,该连接将返回到池中,而不是通过物理方式关闭连接的开销.这意味着在任何给定时间点,将有合理数量的数据库连接,其中V$SESSION中的STATUS为"INACTIVE".完全正常.

Normally, the middle tier application server creates a connection pool. When your code requests a connection, it gets an already open connection from the pool rather than going through the overhead of spawning a new connection to the database. When your code closes a connection, the connection is returned to the pool rather than going through the overhead of physically closing the connection. That means that there will be a reasonable number of connections to the database where the STATUS in V$SESSION is "INACTIVE" at any given point in time. That's perfectly normal.

即使在负载下,来自中间层的大多数数据库连接在大多数情况下也是无效"的.状态"INACTIVE"仅表示运行查询的那一刻,该会话未执行SQL语句.大多数连接将大部分时间都花在连接池中,等待Java会话打开它们,或者等待Java会话对数据进行处理,或者等待网络在计算机之间传输数据.

Even under load, most database connections from a middle tier are "INACTIVE" most of the time. A status of "INACTIVE" merely means that at the instant you ran the query, the session was not executing a SQL statement. Most connections will spend most of their time either sitting in the connection pool waiting for a Java session to open them or waiting on the Java session to do something with the data or waiting on the network to transfer data between the machines.

您是否真的收到错误消息(即ORA-00020:超出了最大进程数)?还是只是对V$SESSION中的条目数量感到困惑?

Are you actually getting an error (i.e. ORA-00020: maximum number of processes exceeded)? Or are you just confused by the number of entries in V$SESSION?

这篇关于通过JDBC在Oracle中进行的非活动会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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