2013年9月26日星期四

Database update operation is unsuccessful , nor error. We look .

Code is as follows :
getSeatSql = "select top" + ticketCount + "seatnum, state"
+ "from dbus_seat with (index (seat), updlock)"
+ "where busnum = '" + busnum_seat
+ "'and setoutdate ='" + setoutdate + "'and state = 0";
try {
conn.setAutoCommit (false);
rs = s.executeQuery (getSeatSql);
while (rs.next ()) {
seats.add (rs.getInt ("seatnum") + "");
seatstatus.add (rs.getInt ("state") + "");
}
rs.close ();
if (seats.size () throw new Exception (" The seats have been sold , or not enough seats " ) ;
} else {/ / account for the seat
String updateSeatSql = "update dbus_seat set state = 1 where busnum = '"
+ busnum_seat
+ "'and setoutdate ='"
+ setoutdate
+ "'";
for (int i = 0; i String sn = seats.get (i);
String updatesql = updateSeatSql + "and seatnum =" + sn;
s.executeUpdate (updatesql);
}
System.out.println (" Train " + busnum_seat + " modified seat state success , the seat :" + seats);
}
conn.commit () ;/ / modify seating state , occupying a seat complete
} catch (Exception f) {
conn.rollback ();
System.out.println (" Train " + busnum_seat + " failed state to modify the seat , the seat :" + seats);
throw f;
}

This code is running at its peak , occasionally s.executeUpdate (updatesql); This executes no effect, but there is no error. Help us to see what is the problem that way .
------ Solution ---------------------------------------- ----
peak time to meet such a situation, it is estimated that you did not do sync , there may be other places modification statement is not submitted , resulting in a thread blocking
----- - For reference only ---------------------------------------
is sometimes no What effect has the effect is still there ?
------ For reference only -------------------------------------- -
break point to see if the statement is executed to update the ....
------ For reference only ------------------- --------------------
fact, has been running for some time, no problem . On New Year these days , one day about 1 , 2 look. One minute is probably the way to run 20 times .
------ For reference only -------------------------------------- -
their top , we look at the help .
------ For reference only -------------------------------------- -
problems found . Elsewhere in the program has been modified . Weighs. Thank oZouBianBian reminder .
------ For reference only -------------------------------------- -
is synchronized not doing what, I also encountered the same problem
13:52:38.155
13:52:38.283
memory database using H2 , the front behind a successful implementation of no effect, not an error
above is the time

没有评论:

发表评论