代码如下:
int num=0;
while(当某条件满足时){
try{
num++;
String sql="insert into QC.FTP (key,pass,stime,ip,stan) values('q','q','q','q',"+new Integer(num).toString()+")"; stmt.executeUpdate(sql);
}catch(Exception e){
continue;
}}上述循环执行第一次时能够成功执行insert语句,但是执行第二次循环时报错:SQL命令未正确结束。但是把上述sql语句放到SQL plus里面依次执行则没有问题,请问是哪里出了问题啊?
int num=0;
while(当某条件满足时){
try{
num++;
String sql="insert into QC.FTP (key,pass,stime,ip,stan) values('q','q','q','q',"+new Integer(num).toString()+")"; stmt.executeUpdate(sql);
}catch(Exception e){
continue;
}}上述循环执行第一次时能够成功执行insert语句,但是执行第二次循环时报错:SQL命令未正确结束。但是把上述sql语句放到SQL plus里面依次执行则没有问题,请问是哪里出了问题啊?
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(sqlText);
for (int i = 0; i < xxx.size(); i++) {
pstmt.setLong(...);
pstmt.addBatch();
if (i % 500 == 0) {
pstmt.executeBatch();
conn.commit();
pstmt.clearBatch();
}
}
pstmt.executeBatch();
conn.commit();
} catch (SQLException e1) {
try {
conn.rollback();
} catch (SQLException e) {
logWriter.error(e);
}
logWriter.error(e1);
} finally {
DBConnection.closeResource(conn, null, pstmt);
}