Topic: selectByPrimary()方法问题。

  Print this page

1.selectByPrimary()方法问题。 Copy to clipboard
Posted by: valen
Posted on: 2004-09-20 16:21

我在使用了 con.setAutoCommit(false);之后,第一次执行没有问题,第二次执行含有查询语句的方法时候又

出现下面的异常,请问是什么问题?接着第三次执行又正常,请问是什么原因呢,我在jbuilder9中开发,查找

方法如下:

private boolean selectByPrimarykey(String primaryKey) throws Exception{
String str="select au_id from authors where au_id='"+primaryKey+"'";
con.setAutoCommit(false);
boolean result = false;
System.out.println("调用selectByPrimaryKey()");
try {
Statement pre=con.createStatement();
ResultSet rs = pre.executeQuery(str);
result = rs.next();
System.out.println("selectByPrimaryKey()-result="+result);
rs.close();
pre.close();
}
catch (SQLException ex){System.out.println("selectByPrimaryKey()出现异常!"+ex);
}
con.setAutoCommit(defaultCommit);
//con.close();
return result;
}
java.sql.SQLException: The transaction is no longer active - status: 'Committed'. No further JDBC

access is allowed within this transaction.

(缩略图,点击图片链接看原图)


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923