当前位置: 技术问答>java相关
我关闭Connection为什么会出错?
来源: 互联网 发布时间:2017-04-20
本文导语: 我在getConnection后,从数据库select记录后 使用Connection.close()方法关闭连接,就出现了: java.lang.StackOverflowError at java.util.PropertyResourceBundle.handleGetObject(PropertyResourceBundle.java:105) at java.util.ResourceBundle.getObject(ResourceBundle....
我在getConnection后,从数据库select记录后
使用Connection.close()方法关闭连接,就出现了:
java.lang.StackOverflowError
at java.util.PropertyResourceBundle.handleGetObject(PropertyResourceBundle.java:105)
at java.util.ResourceBundle.getObject(ResourceBundle.java:376)
at java.util.ResourceBundle.getString(ResourceBundle.java:354)
at oracle.jdbc.dbaccess.Message11.msg(Message11.java:47)
at oracle.jdbc.dbaccess.DBError.findMessage(DBError.java:602)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:207)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
at oracle.jdbc.driver.OracleConnection.rollback(OracleConnection.java:867)
at com.codestudio.sql.PoolManConnection.clean(Unknown Source)
at com.codestudio.sql.PoolManConnection.sendErrorEvent(Unknown Source)
at com.codestudio.sql.PoolManConnection.setAutoCommit(Unknown Source)
at com.codestudio.sql.PoolManConnection.clean(Unknown Source)
at com.codestudio.sql.PoolManConnection.sendErrorEvent(Unknown Source)
at com.codestudio.sql.PoolManConnection.setAutoCommit(Unknown Source)
at com.codestudio.sql.PoolManConnection.clean(Unknown Source)
at com.codestudio.sql.PoolManConnection.sendErrorEvent(Unknown Source)
at com.codestudio.sql.PoolManConnection.setAutoCommit(Unknown Source)
at com.codestudio.sql.PoolManConnection.clean(Unknown Source)
at com.codestudio.sql.PoolManConnection.sendErrorEvent(Unknown Source)
at com.codestudio.sql.PoolManConnection.setAutoCommit(Unknown Source)
at com.codestudio.sql.PoolManConnection.clean(Unknown Source)
at com.codestudio.sql.PoolManConnection.sendErrorEvent(Unknown Source)
at com.codestudio.sql.PoolManConnection.setAutoCommit(Unknown Source)
……
如果我不关闭Connection ,就不会出错了,有谁知道原因吗?请告之
谢谢!
使用Connection.close()方法关闭连接,就出现了:
java.lang.StackOverflowError
at java.util.PropertyResourceBundle.handleGetObject(PropertyResourceBundle.java:105)
at java.util.ResourceBundle.getObject(ResourceBundle.java:376)
at java.util.ResourceBundle.getString(ResourceBundle.java:354)
at oracle.jdbc.dbaccess.Message11.msg(Message11.java:47)
at oracle.jdbc.dbaccess.DBError.findMessage(DBError.java:602)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:207)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
at oracle.jdbc.driver.OracleConnection.rollback(OracleConnection.java:867)
at com.codestudio.sql.PoolManConnection.clean(Unknown Source)
at com.codestudio.sql.PoolManConnection.sendErrorEvent(Unknown Source)
at com.codestudio.sql.PoolManConnection.setAutoCommit(Unknown Source)
at com.codestudio.sql.PoolManConnection.clean(Unknown Source)
at com.codestudio.sql.PoolManConnection.sendErrorEvent(Unknown Source)
at com.codestudio.sql.PoolManConnection.setAutoCommit(Unknown Source)
at com.codestudio.sql.PoolManConnection.clean(Unknown Source)
at com.codestudio.sql.PoolManConnection.sendErrorEvent(Unknown Source)
at com.codestudio.sql.PoolManConnection.setAutoCommit(Unknown Source)
at com.codestudio.sql.PoolManConnection.clean(Unknown Source)
at com.codestudio.sql.PoolManConnection.sendErrorEvent(Unknown Source)
at com.codestudio.sql.PoolManConnection.setAutoCommit(Unknown Source)
at com.codestudio.sql.PoolManConnection.clean(Unknown Source)
at com.codestudio.sql.PoolManConnection.sendErrorEvent(Unknown Source)
at com.codestudio.sql.PoolManConnection.setAutoCommit(Unknown Source)
……
如果我不关闭Connection ,就不会出错了,有谁知道原因吗?请告之
谢谢!
|
cs = con.createStatement();
rs = cs.getResultSet();
用如下方法关闭数据库试试(按顺序)
if (rs != null) rs.close();
if (cs != null) ps.close();
if (con != null) con.close();
rs = cs.getResultSet();
用如下方法关闭数据库试试(按顺序)
if (rs != null) rs.close();
if (cs != null) ps.close();
if (con != null) con.close();
|
要看db类里怎么写了,给出bean代码!!!