informix循环查询为何老是锁表
public void copyCardTemp(Map dataMap,String id) throws Exception {
String idCondition = TbDpTemplate.TEMPLATE_ID.toSqlEQ(id);
Map tempMap = BizDB.getOneRowAsMap(TbDpTemplate.TABLE, idCondition);
Connection conn = BizDB.getConn() ;
try {
//复制模板
String condition = TbDpTemplate.TEMPLATE_NO.toSqlEQ(dataMap.get(TbDpTemplate.TEMPLATE_NO.name));
Integer count = BizDB.getCount(TbDpTemplate.TABLE, condition);
if (count > 0)
{
throw new Exception("卡模板号已经存在");
}
long templateId = SequenceGen.getInstance().nextValue(TbDpTemplate.TABLE);
dataMap.put(TbDpTemplate.TEMPLATE_ID.name, templateId);
dataMap.put(TbDpTemplate.CREATE_DATE.name, new Date());
dataMap.put(TbDpTemplate.BANK_ID.name, Constants.FLAG_PUBDATA_ORG);
try
{
BizDB.insert(conn,TbDpTemplate.TABLE, dataMap);
} catch (Exception e)
{
LogProcess.error(this.getClass(), "复制卡模板错误信息-" + e.getMessage());
throw new Exception("卡模板复制出错:"+e.getMessage());
}
//复制模板对应的数据项
try
{
//查出该模板对应的应用list
String appList = tempMap.get(TbDpTemplate.APP_LIST.name).toString();
String []listTemp = appList.split(",");
for(int i=0;i<listTemp.length;i++)
{
//查数据项表中apptype对应该模板应用的所有记录
String typeCondition = TbDpTempDateApp.APP_TYPE.toSqlEQ(listTemp[i]);
String tempIdCondition = TbDpTempDateApp.TEMPLATE_ID.toSqlEQ(id);
String addCondition = typeCondition+" and "+tempIdCondition;
List itemList = BizDB.searchAsMapList(TbDpTempDateApp.TABLE, addCondition);
for (Iterator iter = itemList.iterator(); iter.hasNext();)
{
long itemId = SequenceGen.getInstance().nextValue(TbDpTempDateApp.TABLE);
//组装数据项map
Map map = (Map) iter.next();
Map newMap = new HashMap();
//插入新数据项ID
newMap.put(TbDpTempDateApp.APP_ITEM_ID.name, itemId);
//插入当前所复制的应用类型编号
newMap.put(TbDpTempDateApp.APP_TYPE.name, listTemp[i]);
newMap.put(TbDpTempDateApp.APP_NAME.name, map.get(TbDpTempDateApp.APP_NAME.name).toString());
newMap.put(TbDpTempDateApp.ITEM_TAG.name, map.get(TbDpTempDateApp.ITEM_TAG.name).toString());
newMap.put(TbDpTempDateApp.ITEM_LEN.name, map.get(TbDpTempDateApp.ITEM_LEN.name).toString());
newMap.put(TbDpTempDateApp.ITEM_VALUE.name, map.get(TbDpTempDateApp.ITEM_VALUE.name).toString());
//插入新模板ID
newMap.put(TbDpTempDateApp.TEMPLATE_ID.name, templateId);
BizDB.insert(conn,TbDpTempDateApp.TABLE, newMap);
}
}
} catch (Exception e)
{
LogProcess.error(this.getClass(), "数据项复制错误信息-" + e.getMessage());
throw new Exception("数据项复制出错:"+e.getMessage());
}
conn.commit();
conn.close();
} catch (Exception e)
{
LogProcess.error(this.getClass(), "复制卡模板错误信息-" + e.getMessage());
conn.rollback();
throw new Exception(e.getMessage());
}finally
{
if (conn != null && !conn.isClosed())
{
BizDB.closeConn(conn) ;
}
}
}
}
当listTemp.length大于1时就报锁表,我只是查询,又没有操作,而且表的锁级别是行锁
[解决办法]
没有一句SQL,怎么分析?
[解决办法]
同上