Hi, Maybe you need to move "SingletonConnection.closeConnection();" inside a finally block?
Regards, Thomas On Sunday, May 4, 2014, Noel Grandin <[email protected]> wrote: > Something is wrong with your description because the error message doesn't > match the SQL. Maybe you left part if the message out? > > The short term fix is to increase the lock timeout using the > LOCK_TIMEOUT=123 extension to the URL. > > On Saturday, 3 May 2014, > <[email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');>> > wrote: > >> Hello to all, >> this is the part of code that locks the table: >> >> public void des(String id, String far) throws Exception { >> Connection conn=SingletonConnection.getConnection(); >> >> PreparedStatement ps3=conn.prepareStatement("DELETE FROM TABLE WHERE >> FK_ID=? AND FK_COD=? "); >> >> ps3.setString(1, id); >> ps3.setString(2, far); >> >> *int i = ps3.executeUpdate();* >> >> * if(i==0){ * >> * //ERROR IS HERE* >> * SingletonConnection.closeConnection();* >> * throw new Exception("ERROR 505"); * >> * }* >> conn.commit(); >> SingletonConnection.closeConnection(); >> >> } >> >> --------------------------- >> >> *CODE SingletonConnection :* >> --------------------- >> public class SingletonConnection { >> private static Connection conn; >> private SingletonConnection() throws Exception { >> >> Class.forName("org.h2.Driver"); >> conn = DriverManager.getConnection("jdbc:h2:tcp://localhost/~/FAR", >> "admin", "admin"); >> conn.setAutoCommit(false); >> } >> public static Connection getConnection() throws Exception { >> if (conn==null) new SingletonConnection(); >> return conn; >> } >> public static void closeConnection() throws Exception { >> conn=null; >> } >> >> } >> -------------------------------------- >> >> When " int i = ps3.executeUpdate(); " returns 0 , I get this error: >> >> model.exceptions.SchedaException: org.h2.jdbc.JdbcSQLException: Timeout >> trying to lock table "TABLE"; SQL statement: >> SELECT * FROM TABLE >> >> Some suggestion ? Thanks in advance. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "H2 Database" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/h2-database. >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to > [email protected]<javascript:_e(%7B%7D,'cvml','h2-database%[email protected]');> > . > To post to this group, send email to > [email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');> > . > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
