我与TOMCAT不得不说的二三事
/************************************
* release the connection
* @param conn Connection
* @param stmt Statement
* @param pstmt PreparedStatement
************************************/
public synchronized
void freeConnection(Connection conn,
Statement stmt,
PreparedStatement pstmt) {
try {
//close Statement
if (stmt != null) {
stmt.close();
stmt = null;
//log("Close Statement......");
}
//close PreparedStatement
if (pstmt != null) {
pstmt.close();
pstmt = null;
//log("Close PreparedStatement......");
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
try {
//close Connection
if (conn != null) {
conn.close();
conn = null;
//log("Close Connection......");
}
}
catch (SQLException e) {
log(e, "释放资源出错!");
}
}
/************************************
* write log file.
* @param s String
************************************/
private
void log(String s) {
if (VERBOSE) {
System.out.println(new java.util.Date() + ":" + s);
//logger.info(new java.util.Date()+s);
}
}
/************************************
* write log file.
* @param ex Object
************************************/
private
void logerr(Object ex) {
if (VERBOSE) {
//System.out.println(new java.util.Date()+":"+s);
//logger.error(ex);
}
}
