在同一个事务中肯定是可以同时进行insert和delete操作的。
是你写的程序本身就有问题。你好好看看下面的连接 吧。
http://community.csdn.net/Expert/topic/3285/3285254.xml?temp=.0951044
是你写的程序本身就有问题。你好好看看下面的连接 吧。
http://community.csdn.net/Expert/topic/3285/3285254.xml?temp=.0951044
解决方案 »
- 用一个url进行sso登陆并访问指定的页面,但是会出现登陆失败的原因,求助
- freemarker标签怎么显示的?
- 部署EJB模块报错
- 谁有java ee 5的源代码啊?
- 用ajax访问数据库,第二次访问时查询的是缓存
- structs中download时,有一个弹出的空白页,请问如何去掉这个页?急!
- jasper报表用html输出图表不能显示,如何解决?
- struts中的selected问题
- 能否能够给一个dao+jdbc或者dao+hibernate实际例子,或者给我个方法去了解一下,谢谢!
- struts在tomcat下正常,放到weblogic就不行了,怎么回事?
- 【50分】今天发现 JBuilderX 的一个问题!!求教!!!
- 请教如何读取informix中text字段?
同意楼上的观点!
PreparedStatement pts = con.prepareStatement(insertSQL);
PreparedStatement pts2 = con.prepareStatement(deleteSQL);
private void testDBT(java.sql.Connection con, String insert, String update)
throws Exception {
try {
con.setAutoCommit(false);
java.sql.Statement st = con.createStatement();
st.executeUpdate(insert);
st.executeUpdate(update);
con.commit();
}
catch (Exception e) {
con.rollback();
}
}
String deleteSQL = "Delete from table1 where col1 = ?";con.setAutoCommit(false);for (int index = 0; index < list.size(); index++)
{
PreparedStatement pts = con.prepareStatement(insertSQL);
pts.setInt(1,index);
pts.executeUpdate(); pts = con.prepareStatement(deleteSQL);
pts.setInt(1,index);
pts.executeUpdate();
}con.commit();
String deleteSQL = "Delete from table1 where col1 = ?";con.setAutoCommit(false);for (int index = 0; index < list.size(); index++)
{
PreparedStatement pts = con.prepareStatement(insertSQL);
pts.setInt(1,index);
pts.executeUpdate(); pts = con.prepareStatement(deleteSQL);
pts.setInt(1,index);
pts.executeUpdate();
}con.commit();
就是这样的