/**
* 卡数据写入tcb_card
*
* @throws SQLException
*/
public void cardDataInsertTcbCard(final List list,) throws SQLException {
final JdbcTemplate template = new JdbcTemplate(this.getTcb());
template.execute(new ConnectionCallback() {
public Object doInConnection(Connection conn) {
PreparedStatement pstmt = null;
PreparedStatement taskPstmt = null;
PreparedStatement cardApplyPstmt = null;
try {
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(INSERT_CARD_SQL);
taskPstmt = conn.prepareStatement(SQL_UPADTE_TCB_TASK);
cardApplyPstmt = conn
.prepareStatement(SQL_UPADTE_TCB_CARD_APPLY);
System.out.println("-----------------------");
for (long i = 0; i < list.size(); i++) {
System.out.println("---------------"+i);
pstmt.setString(1, "");
pstmt.setString(2, "");
pstmt.setString(3, "");
pstmt.setString(4,"");
pstmt.setString(5, "");
pstmt.setString(6, "");
pstmt.setString(7, "");
pstmt.setString(8,"" );
pstmt.setString(9, "");
pstmt.setString(10, "");
pstmt.addBatch();
if (i % 10000 == 0) {
System.out.println("---------------"+i+"========"+i);
pstmt.executeBatch();
pstmt.clearBatch();
}
}
pstmt.executeBatch();
taskPstmt.setString(1, "");
taskPstmt.setString(2, "");
taskPstmt.setString(3, "");
taskPstmt.setString(4, "");
taskPstmt.setString(5, "");
taskPstmt.execute();
cardApplyPstmt.setString(1, "");
cardApplyPstmt.setString(2, "");
cardApplyPstmt.setString(3, "");
cardApplyPstmt.setString(4, "");
cardApplyPstmt.execute();
conn.commit();
} catch (SQLException e) {
try {
conn.rollback();
} catch (SQLException e1) {
}
} finally {
if (pstmt != null) {
try {
pstmt.close();
} catch (SQLException e) {
}
}
if (taskPstmt != null) {
try {
taskPstmt.close();
} catch (SQLException e) {
}
}
if (cardApplyPstmt != null) {
try {
cardApplyPstmt.close();
} catch (SQLException e) {
}
}
}
return null;
}
});
}
//插入卡数据
private static final String INSERT_CARD_SQL = "insert into card(ID,CUSTOMER_ID,VISIBLE_PWD,INIT_PWD,SECOND_TRACK,STATUS,MERCHANT_ID,BATCH_NO,CARD_NAME,THIRD_TRACK) values(?,?,?,?,?,?,?,?,?,?)";
//更新任务表状态
private static final String SQL_UPADTE_TCB_TASK = "update TCB_TASK t set t.LAST_ACTION=?, t.LAST_COMMENT=? , t.WORKFLOW_ID=?, t.STAGE=? where t.TASK_ID=?";
//更新卡申请表状态
private static final String SQL_UPADTE_TCB_CARD_APPLY = "update TCB_CARD_APPLY r set r.STATUS=?, r.EXPORT_COMMNET=? , r.EXPORT_PERSON=? where r.TBID=?";
数据库是oracal10g,spring+struts+ibatis,因为原先事物处理不能正常进行,所以改成这样
为什么我执行插入500000的数据时服务器断网,造成数据库死锁,不能再插入这些数据,但可以插入其它的数据,程序什么地方除了问题?怎样才可以使断网时不发生死锁。急!急!急!