public void inputCusChargeList(CorChargeDTO corChargeDTO) throws PafaDAOException {
// Map map=new HashMap();
// map.put("partyNo",corChargeDTO.getPartyNo());
// map.put("parentAccNum",corChargeDTO.getParentAccNum());
// map.put("addTellerNo",corChargeDTO.getAddTellerNo());
// map.put("auditTellerNo",corChargeDTO.getAuditTellerNo());
// map.put("accList",corChargeDTO.getAccList());
// this.getSqlMapClientTemplate().queryForObject("chargeAccManage_input",map);
// logger.debug("retcode:"+map.get("retcode"));
// logger.debug("retmessage:"+map.get("retmessage"));
Connection con = null;
CallableStatement stmt = null;
String retcode="";
String retmessage="";
try {
con = ((WLConnection)getSqlMapClientTemplate().getDataSource().getConnection()).getVendorConnection();
if (con != null) {
ARRAY aArray = this.getArray(con,dbTypeUserName+".BCOMS_CORCHARGE_ACC_TYPE",dbTypeUserName+".BCOMS_CORCHARGE_ACC_TBL_TYPE",corChargeDTO.getAccList());
//该函数调用的第二三个参数必须大写
stmt = con.prepareCall("call BCOMS_Corclient_others_pkg.bcoms_inputCorCharge_pro(?,?,?,?,?,?,?)"); //调用某个存储过程
stmt.setString(1,corChargeDTO.getPartyNo());
stmt.setString(2,corChargeDTO.getParentAccNum());
stmt.setString(3,corChargeDTO.getAddTellerNo());
stmt.setString(4,corChargeDTO.getAuditTellerNo());
((OracleCallableStatement) stmt).setARRAY(5, aArray);
stmt.registerOutParameter(6, java.sql.Types.VARCHAR);
stmt.registerOutParameter(7, java.sql.Types.VARCHAR);
stmt.execute();
retcode = stmt.getString(6);
retmessage=stmt.getString(7);
logger.debug("retcode:"+retcode);
logger.debug("retmessage:"+retmessage);
}
} catch (Exception e) {
e.printStackTrace();
throw new PafaRuntimeException("embis.bcoms.db.error",e);
} finally {
try {
if(stmt!=null){
stmt.close();//释放数据库连接
}
if(con!=null){
con.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.error("关闭连接时发生异常", e);
throw new PafaRuntimeException("embis.bcoms.db.error",e);
}
}
}
private ARRAY getArray(Connection con, String OracleObj,
String Oraclelist, List objlist) throws Exception {
ARRAY list = null;
if (objlist != null && objlist.size() > 0) {
StructDescriptor structdesc = new StructDescriptor(OracleObj, con);
STRUCT[] structs = new STRUCT[objlist.size()];
Object[] result = new Object[0];
for (int i = 0; i < objlist.size(); i++) {
CorChargeDTO chargeDTO= (CorChargeDTO) objlist.get(i);
result = new Object[6];//数组大小应和你定义的数据库对象(AOBJECT)的属性的个数
result[2] =chargeDTO.getAccNum() ; //将list中元素的数据传入result数组
result[3] = chargeDTO.getAccName(); //
structs[i] = new STRUCT(structdesc, con, result);
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor(Oraclelist,
con);
list = new ARRAY(desc, con, structs);
}
return list;
}
项目中采用的是Weblgoic 的数据源 ,JndiObjectFactoryBean ,批量导入list 类型 ,引入了weblgic lib 中oracle 的jdbc的包,直接操作connection.
getVendorConnection()---------------RemoveInfectedConnectionsEnabled 设置上.