52 lines
1.3 KiB
Java
52 lines
1.3 KiB
Java
package com.nms.interceptor;
|
|
|
|
import java.sql.CallableStatement;
|
|
import java.sql.Connection;
|
|
import java.sql.SQLException;
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
import com.jfinal.plugin.activerecord.ICallback;
|
|
|
|
public class SyncStoredProcedure implements ICallback{
|
|
private Logger logger=Logger.getLogger(this.getClass());
|
|
private String proName;
|
|
private String tableName;
|
|
private String filedAndType;
|
|
private String fileds;
|
|
|
|
public SyncStoredProcedure(String proName, String tableName, String filedAndType, String fileds) {
|
|
super();
|
|
this.proName = proName;
|
|
this.tableName = tableName;
|
|
this.filedAndType = filedAndType;
|
|
this.fileds = fileds;
|
|
}
|
|
|
|
@Override
|
|
public Object call(Connection conn) throws SQLException {
|
|
logger.info("开始调用存储过程任务");
|
|
CallableStatement proc=null;
|
|
try{
|
|
proc=conn.prepareCall("{call "+proName+"(?,?,?)}");
|
|
proc.setString(1,tableName);
|
|
proc.setString(2,filedAndType);
|
|
proc.setString(3, fileds);
|
|
proc.execute();
|
|
logger.info("调用存储过程任务结束");
|
|
} catch (Exception e){
|
|
logger.error("调用存储过程任务出现错误 存储过程名称"+proName+" 表名"+tableName+"参数 "+filedAndType+"------"+fileds);
|
|
e.printStackTrace();
|
|
} finally{
|
|
if(conn!=null){
|
|
conn.close();
|
|
}
|
|
if(proc!=null){
|
|
proc.close();
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|