0

I tried inserting a row via JDBC connection in mysql database. Sometime I am unable to write them in the database reason being the same table was being read by some other program. I didn't get any exceptions regarding the failure of query. So how can I know the successful execution of query ???

4

2 回答 2

0

我假设您正在使用preparedstatement 所以您可能正在使用pt.executeUpdate()插入现在pt的对象在哪里PreparedStatement 检查if(pt.executeQuery()>0) 是否为真然后插入成功否则不是

if(pt.executeQuery()>0)
{
System.out.println("inserted");
}
else
{
System.out.println("not inserted");
}
于 2013-09-30T12:44:03.583 回答
0

您应该在具有适当隔离集的事务中执行 INSERT。让司机来处理。

于 2013-09-30T12:43:00.767 回答