数据库连接正在耗尽,而Weblogic连接池完全没问题



>我遇到了一个典型的问题,即 WebLogic 连接池容量低于限制,但 Oracle 数据库连接不断增加,最终达到最大数据库连接大小并停止响应。

我们使用休眠来调用数据库存储过程来更新数据库中的某些记录。

create or replace procedure UPDATE_TIME
(
p_alarmId       NUMBER,
p_clearTime     NUMBER
)
is
v_errorCode NUMBER := 1;
begin
while ( v_errorCode != 0 )
loop
v_errorCode := 0;
begin
update ANNOTATION
set    PARTITION_TIME=p_clearTime 
where ANN_ID = (select ANNOTATION_ID from CORE where ID = p_alarmId) and PARTITION_TIME = 0;
exception
when OTHERS then
v_errorCode := 1;
end;
end loop;
end;
/

最后,WebLogic 事务在 5 分钟后超时,因为套接字超时指定如下所述,但数据库连接永远不会空闲。

<url>jdbc:mysql://localhost:31300/oneodb?socketTimeout=300000</url>

例外:

javax.ejb.EJBException: EJB Exception: ; nested exception is: 
javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: could not execute native bulk manipulation query
...
at Caused by: oracle.net.ns.NetException: Socket read timed out
at oracle.net.ns.Packet.receive(Packet.java:339)

任何意见都非常感谢。谢谢。

我们找到了问题的根本原因。

db 过程内的 while 循环不允许将原始异常抛出到应用程序。删除此循环后,将捕获异常。

Caused by: java.sql.SQLException: ORA-01427: single-row subquery returns more than one row

在 update 命令中指定的内部查询返回 2 行,而预期只返回 1 行。查询已更新为更多约束,并且工作正常。此外,删除了这个不必要的 while 循环。

最新更新