连接oralce一定几率失败是啥问题?
在oralce 9i jdk1.4.2 tomcat5环境,时常出现
无法连接数据:原因IO 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=12519)(ERROR_STACK=(ERROR=(CODE=12519)(EMFI=4))))
或者TNS Network Adapter Failure
据我们技术人员测试说是execUpdate执行一万次可能成功率在95%
代码如下:
public static Connection getConn() {
Connection conn = null;
try {
Class.forName(Consts.DB1_DRIVER);
DriverManager.setLoginTimeout(20);
conn =
DriverManager.getConnection(Consts.DB1_URL,
Consts.DB1_USER,
Consts.DB1_PASSWORD);
}
catch (Exception e) {
Log.fetal( "*ERROR AT getConn(): " +e.getMessage()+ "\n "+ Consts.DB1_URL+Consts.DB1_USER+Consts.DB1_PASSWORD);
}
return conn;
}
public static void execUpdate(String sql) {
Connection conn = null;
Statement stmt = null;
try {
conn = getConn();
conn.setAutoCommit(false);
stmt = conn.createStatement();
stmt.executeUpdate(sql);
conn.commit();
}
catch (Exception e) {
Log.err( "at DBUtil.execUpdate(): " + sql + "\n " + e);
try {
conn.rollback();
}
catch (Exception ex) {
Log.err( "at DBUtil.execUpdate() Rollback Error: " + sql + "\n " + e);
}
}