Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] OracleDB开启PreparedStatement缓存,必现SQLException: Closed Statement的问题 #6198

Open
isaacfourier3 opened this issue Oct 25, 2024 · 0 comments

Comments

@isaacfourier3
Copy link

Database Type

Oracle

Database Version

Oracle19c

Druid Version

1.2.22

JDK Version

Java HotSpot(TM) 64-Bit Server VM 17.0.10

Error SQL

select sysadmi0_.mer_own from sys_admin sysadmi0_ where sysadmi0_.mer_no=? and sysadmi0_.account=?

springboot-3.2 + jpa 调用方法示意。等待一段时间,当连接池有连接被释放后,必然出现java.sql.SQLException: Closed Statement
at oracle.jdbc.driver.OracleClosedStatement.exitImplicitCacheToActive(OracleClosedStatement.java:2957)

	public Object getSingleResult(String sql, List params) {
		Query nativeQuery = entityManager.createNativeQuery(sql);
		for (int i = 0; i < params.size(); i++) {
			nativeQuery.setParameter(i+1, params.get(i));
		}
		return nativeQuery.getSingleResult();
	}

Testcase Code

No response

Stacktrace Info

No response

Error Info

2024-10-25 09:07:54.902 INFO [XNIO-1 task-6] c.l.c.config.LocaleChangeInterceptor.preHandle:129 - change_timezone: sun.util.calendar.ZoneInfo[id="Asia/Seoul",offset=32400000,dstSavings=0,useDaylight=false,transitions=30,lastRule=null]
2024-10-25 09:07:54.903 TRACE[XNIO-1 task-6] o.s.transaction.interceptor.TransactionInterceptor.prepareTransactionInfo:638 - Getting transaction for [c.l.c.trade.service.impl.MerTradeMgrServiceImpl.getGwo]
2024-10-25 09:07:54.904 DEBUG[XNIO-1 task-6] druid.sql.Statement.statementLog:142 - {conn-10006, pstmt-20202} Parameters : [80000, admin]
2024-10-25 09:07:54.904 DEBUG[XNIO-1 task-6] druid.sql.Statement.statementLog:142 - {conn-10006, pstmt-20202} Types : [BIGINT, VARCHAR]
2024-10-25 09:07:54.904 DEBUG[XNIO-1 task-6] druid.sql.Statement.statementLog:142 - {conn-10006, pstmt-20202, rs-51936} query executed. 0.615907 millis. select sysadmi0_.ma_mer_own_gw as col_0_0_ from sys_admin sysadmi0_ where 1=1 and sysadmi0_.mer_no=? and sysadmi0_.account=?
2024-10-25 09:07:54.905 DEBUG[XNIO-1 task-6] druid.sql.Statement.statementLog:142 - {conn-10006, pstmt-20202} clearParameters. 
2024-10-25 09:07:54.905 DEBUG[XNIO-1 task-6] druid.sql.Statement.statementLog:142 - {conn-10006, stmt-20202} clearBatch. 
2024-10-25 09:07:54.905 TRACE[XNIO-1 task-6] o.s.transaction.interceptor.TransactionInterceptor.commitTransactionAfterReturning:667 - Completing transaction for [c.l.c.trade.service.impl.MerTradeMgrServiceImpl.getGwo]
2024-10-25 09:07:54.906 ERROR[XNIO-1 task-6] c.l.c.settl.dao.impl.TransactionsettlDAOImpl.getxxx:235 - java.sql.SQLException: Closed Statement
	at oracle.jdbc.driver.OracleClosedStatement.exitImplicitCacheToActive(OracleClosedStatement.java:2957)
	at oracle.jdbc.driver.OraclePreparedStatementWrapper.exitImplicitCacheToActive(OraclePreparedStatementWrapper.java:1249)
	at com.alibaba.druid.util.OracleUtils.exitImplicitCacheToActive(OracleUtils.java:84)
	at com.alibaba.druid.pool.PreparedStatementPool.get(PreparedStatementPool.java:65)
	at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:364)
	at c.l.c.settl.dao.impl.xxxDAOImpl.getxxx(xxxDAOImpl.java:188)
	at jdk.internal.reflect.GeneratedMethodAccessor389.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:351)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:765)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
@isaacfourier3 isaacfourier3 changed the title [BUG] OracleDB开启PreparedStatement缓存,必然出现SQLException: Closed Statement [BUG] OracleDB开启PreparedStatement缓存,必现SQLException: Closed Statement的问题 Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant