public boolean execute() {
//Adapter.DB cc=null;
Connection conn=null;
Statement stmt = null;
try{
//cc = Adapter.DB.binding("ff6aa24f543043311ca87789ab71619b");
conn = DBSql.open();
conn.setAutoCommit(false);//取消自动提交
stmt=conn.createStatement();
//执行insert或update语句
stmt.addBatch("update BO_TEST set score=10 where id=13324642");
stmt.addBatch("update BO_TEST set score=12 where id=13324643");
stmt.addBatch("update BO_TEST set score='一百' where id=13359038");
stmt.executeBatch();
conn.commit();
}catch(Exception e){
try {
conn.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}finally{
//Adapter.DB.close(conn, stmt, null);
DBSql.close(conn, stmt, null);
}
return false;
}
java与oracle事务的结合
最新推荐文章于 2023-04-03 10:36:50 发布
本文展示了一个使用Java进行数据库操作的例子,通过批量执行SQL更新语句来修改数据库表中的记录。涉及连接创建、批量更新及异常处理等关键步骤。
1485

被折叠的 条评论
为什么被折叠?



