(1)连接对象
[08-12-3 8:49:10:993 CST] 0000065e SystemErr R java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01000: maximum open cursors exceeded
这个问题和WAS也有一定的关系,随WAS版本不同,其JDBC对于PreparedStatement缓存设置也不同,在咱们的程序中,如果出现这个问题,说明PreparedStatement
\Statement对象的引用,并没有关闭。
一般程序上
pstmt = connection.prepareStatement(...);
pstmt.executeUpdate();
这样来使用,所以我们还需要加入一句
pstmt = connection.prepareStatement(...);
pstmt.executeUpdate();
pstmt.close();
这样就可以有效的防止此类问题的发生,也不容易造成内存溢出的错误。
如果不及时关闭的话,DBMS会分配一个指针,实时对PreparedStatement对象进行遍历,加大系统开销。
通过查看VSS上源代码,发现很多数据库连接对象都没有关闭,有很多没有关闭的,还有的是写了关闭,但似乎没有执行到,如下
finally {
try {
if (!conn.isClosed()) {
if (!conn.getAutoCommit()) {
conn.rollback();
conn.setAutoCommit(true);
log
.error("TacticSearchServlet|Error while closing connection.");
}
conn.close();
}
} catch (Exception e) {
System.out.println("异常:"+e.getMessage());
}
执行finally的时候,如果出错了,那么就进入了finally的catch,而finally try中才有数据连接对象的关闭。
综上所述,需要开发检查PreparedStatement对象和Connection对象的关闭情况
(2)类型转换
[08-12-3 9:00:12:092 CST] 00000681 SystemErr R java.lang.NumberFormatException: For input string: ""
从错误日志找到当时是执行com.hss.mcs.report.servlet.Sale_Analysis_Servlet,查看代码发现,这个属于“数据营销平台—数据销售分析”调用的,查看代码,发现是int I_jgbs=(new Integer(I_jgbs1)).intValue()这里对数据类型进行了转化,而I_jgbs1这个参数会取到空值,所以程序对转化也需要做一个修改。