根据需要,我在执行更新操作时需要频繁的执行更新操作,而且一次需要更新多个表,每个表更新的内容都是一样的,我现在的做法是使用批处理,一个表一个表更新,下面的代码是我更新操作中的其中一段:con.setAutoCommit(false);
stmt.addBatch("update PDMM31A.表A set NAME='张三' where NAME is null ");
stmt.addBatch("update PDMM31A.表B set NAME='张三' where NAME is null ");
stmt.addBatch("update PDMM31A.表C set NAME='张三' where NAME is null ");
stmt.addBatch("update PDMM31A.表D set NAME='张三' where NAME is null ");
stmt.addBatch("update PDMM31A.表E set NAME='张三' where NAME is null ");
……
stmt.executeBatch();
con.commit();
con.setAutoCommit(true);
我总觉得一个表一个表更新很繁烦,而且效率也低,请教高手有没有什么简单的方法啊。
stmt.addBatch("update PDMM31A.表A set NAME='张三' where NAME is null ");
stmt.addBatch("update PDMM31A.表B set NAME='张三' where NAME is null ");
stmt.addBatch("update PDMM31A.表C set NAME='张三' where NAME is null ");
stmt.addBatch("update PDMM31A.表D set NAME='张三' where NAME is null ");
stmt.addBatch("update PDMM31A.表E set NAME='张三' where NAME is null ");
……
stmt.executeBatch();
con.commit();
con.setAutoCommit(true);
我总觉得一个表一个表更新很繁烦,而且效率也低,请教高手有没有什么简单的方法啊。
最多你写 store procedure,感觉上和你这个差不多,你这个还不用编程调试。