主题:异常处理的问题(在线等)
帮我看看哪里有错!!
package com.org
import com.org.database.DBConnection;
import com.org.entity.LogFile;
import java.sql.Connection;
import java.sql.PreparedStatement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class AddLog
{
public AddLog()
{
}
public boolean addLog(LogFile logFile)
{
DBConnection dbconn;
PreparedStatement pStat;
Connection conn;
Log log;
String modulename;
String keycode;
String operator;
String operatordate;
String operatorname;
String sql;
String remark;
String sqlstr;
dbconn = null;
pStat = null;
conn = null;
log = LogFactory.getLog(getClass());
modulename = logFile.getModulename();
keycode = logFile.getKeycode();
operator = logFile.getOperator();
operatordate = logFile.getOperatordate();
operatorname = logFile.getOperatorname();
sql = logFile.getSql();
remark = logFile.getRemark();
sqlstr = "INSERT INTO logfile(modulename,keycode,operator,operatordate,operatorname,sql,remark)VALUES(?,?,?,?,?,?,?)";
dbconn = new DBConnection();
conn = dbconn.getConnectionFromProxool();
pStat = conn.prepareStatement(sqlstr);
pStat.setString(1, modulename);
pStat.setString(2, keycode);
pStat.setString(3, operator);
pStat.setString(4, operatordate);
pStat.setString(5, operatorname);
pStat.setString(6, sql);
pStat.setString(7, remark);
pStat.execute();
dbconn.closePreparedStatement(pStat);
dbconn.closeConnection(conn);
return true;
Exception e;
e;
log.error((new StringBuilder("addLog \u51FA\u73B0\u5F02\u5E38\uFF1A")).append(e.getMessage()).toString());
dbconn.closePreparedStatement(pStat);
dbconn.closeConnection(conn);
return false;
Exception exception;
exception;
dbconn.closePreparedStatement(pStat);
dbconn.closeConnection(conn);
throw exception;
}
}
package com.org
import com.org.database.DBConnection;
import com.org.entity.LogFile;
import java.sql.Connection;
import java.sql.PreparedStatement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class AddLog
{
public AddLog()
{
}
public boolean addLog(LogFile logFile)
{
DBConnection dbconn;
PreparedStatement pStat;
Connection conn;
Log log;
String modulename;
String keycode;
String operator;
String operatordate;
String operatorname;
String sql;
String remark;
String sqlstr;
dbconn = null;
pStat = null;
conn = null;
log = LogFactory.getLog(getClass());
modulename = logFile.getModulename();
keycode = logFile.getKeycode();
operator = logFile.getOperator();
operatordate = logFile.getOperatordate();
operatorname = logFile.getOperatorname();
sql = logFile.getSql();
remark = logFile.getRemark();
sqlstr = "INSERT INTO logfile(modulename,keycode,operator,operatordate,operatorname,sql,remark)VALUES(?,?,?,?,?,?,?)";
dbconn = new DBConnection();
conn = dbconn.getConnectionFromProxool();
pStat = conn.prepareStatement(sqlstr);
pStat.setString(1, modulename);
pStat.setString(2, keycode);
pStat.setString(3, operator);
pStat.setString(4, operatordate);
pStat.setString(5, operatorname);
pStat.setString(6, sql);
pStat.setString(7, remark);
pStat.execute();
dbconn.closePreparedStatement(pStat);
dbconn.closeConnection(conn);
return true;
Exception e;
e;
log.error((new StringBuilder("addLog \u51FA\u73B0\u5F02\u5E38\uFF1A")).append(e.getMessage()).toString());
dbconn.closePreparedStatement(pStat);
dbconn.closeConnection(conn);
return false;
Exception exception;
exception;
dbconn.closePreparedStatement(pStat);
dbconn.closeConnection(conn);
throw exception;
}
}