我在 spring3 项目中工作。当我运行我的代码时,有时我会得到一些特定功能的 Jdbc 连接异常,但其他功能工作得很好。而且这个异常不会重复发生,但有时会发生,所以我不知道错误在哪里。 请帮我解决这个问题。
<[weblogic.servlet.internal.WebAppServletContext@1b6e978 - appName: '_auto_generated_ear_', name: 'ae', context-path: '/ae'] Root cause of ServletException. org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Listener refused the connection with the following error: ORA-12519, TNS:no appropriate service handler found The Connection descriptor used by the client was: localhost:1521:XE at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:573) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:674) Truncated. see log file for complete stacktrace java.sql.SQLException: Listener refused the connection with the following error: ORA-12519, TNS:no appropriate service handler found The Connection descriptor used by the client was: localhost:1521:XE at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387) at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:420) at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:165) Truncated. see log file for complete stacktrace
最佳答案
出现这种症状有两个常见原因
- 连接池已耗尽,打开的 Activity 连接过多,下一个客户端无法获取。这可能是连接池泄漏
- 连接池设置不会定期/借用测试空闲连接,因此当 TCP 连接被操作系统截断时(例如:因为操作系统认为它空闲无所事事),连接池仍然认为它是有效的
关于java - org.springframework.jdbc.CannotGetJdbcConnectionException异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17720902/