sql日志,执行前先把sql写进日志。

web_backend_develope
chenlw 8 years ago
parent 9bfc4a8862
commit 81308525b7

@ -69,17 +69,17 @@ public class OracleConnector {
} }
Statement statement = null; Statement statement = null;
try { try {
FileOperateHelper.fileWrite(filePath + ".log", sql + "\r\n");
statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE); ResultSet.CONCUR_UPDATABLE);
resultSet = statement.executeQuery(sql); resultSet = statement.executeQuery(sql);
/* /*
* if(resultSet.next()){ System.out.println(resultSet.getInt(1)); } * if(resultSet.next()){ System.out.println(resultSet.getInt(1)); }
*/ */
FileOperateHelper.fileWrite(filePath + ".log", sql + "\r\n" FileOperateHelper.fileWrite(filePath + ".log", "OK \r\n");
+ "OK \r\n");
} catch (SQLException e) { } catch (SQLException e) {
FileOperateHelper.fileWrite(filePath + ".log", FileOperateHelper.fileWrite(filePath + ".log",
sql + "\r\n" + e.getMessage() + "\r\n"); e.getMessage() + "\r\n");
log.error(Custom4exception.OracleSQL_Except, e); log.error(Custom4exception.OracleSQL_Except, e);
} finally { } finally {
if (null != statement) { if (null != statement) {
@ -121,15 +121,16 @@ public class OracleConnector {
boolean flag = false; boolean flag = false;
Statement statement = null; Statement statement = null;
try { try {
FileOperateHelper.fileWrite(filePath + ".log", sql + "\r\n");
statement = conn.createStatement(); statement = conn.createStatement();
int res = statement.executeUpdate(sql); int res = statement.executeUpdate(sql);
flag = true; flag = true;
FileOperateHelper.fileWrite(filePath + ".log", sql + "\r\n执行结果:" + res FileOperateHelper.fileWrite(filePath + ".log", "执行结果:" + res
+ " \r\n"); + " \r\n");
} catch (SQLException e) { } catch (SQLException e) {
flag = false; flag = false;
FileOperateHelper.fileWrite(filePath + ".log", FileOperateHelper.fileWrite(filePath + ".log",
sql + "\r\n" + e.getMessage() + "\r\n"); e.getMessage() + "\r\n");
log.error(Custom4exception.OracleSQL_Except, e); log.error(Custom4exception.OracleSQL_Except, e);
} }
@ -151,16 +152,17 @@ public class OracleConnector {
boolean flag = false; boolean flag = false;
Statement statement = null; Statement statement = null;
try { try {
FileOperateHelper.fileWrite(filePath + ".log", sql + "\r\n");
statement = conn.createStatement(); statement = conn.createStatement();
int res = statement.executeUpdate(sql); int res = statement.executeUpdate(sql);
flag = true; flag = true;
FileOperateHelper.fileWrite(filePath + ".log", sql + "\r\n 执行结果:"+ res FileOperateHelper.fileWrite(filePath + ".log", "执行结果:"+ res
+ " \r\n"); + " \r\n");
} catch (SQLException e) { } catch (SQLException e) {
flag = false; flag = false;
FileOperateHelper.fileWrite(filePath + ".log", FileOperateHelper.fileWrite(filePath + ".log",
sql + "\r\n" + e.getMessage() + "\r\n"); e.getMessage() + "\r\n");
log.error(Custom4exception.OracleSQL_Except, e); log.error(Custom4exception.OracleSQL_Except, e);
} }
return flag; return flag;

Loading…
Cancel
Save