From: Tim P. <ti...@pa...> - 2006-03-31 10:27:50
|
Update of /usr/cvsroot/melati/src/main/org/melati/poem In directory rama.paneris.org:/tmp/cvs-serv12650/src/main/org/melati/poem Modified Files: PreparedStatementFactory.java Log Message: Add retry loop for MSAccess (grr) Index: PreparedStatementFactory.java =================================================================== RCS file: /usr/cvsroot/melati/src/main/org/melati/poem/PreparedStatementFactory.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- PreparedStatementFactory.java 2 Dec 2004 11:03:06 -0000 1.15 +++ PreparedStatementFactory.java 31 Mar 2006 09:59:52 -0000 1.16 @@ -121,10 +121,37 @@ PreparedStatement statement) { try { if (database.logSQL()) - database.log(new SQLLogEvent(statement.toString() + "(" + sql + ")")); + database.log(new SQLLogEvent("PS about to:" + statement.toString() + "(" + sql + ")")); token.transaction.writeDown(); - ResultSet rs = statement.executeQuery(); + + ResultSet rs = null; + if (database.getDbms().toString() + .equals("org.melati.poem.dbms.MSAccess")){ + // This is due to some uncontrollable + // lazy write caching. + // On my machine it is taking 4s to + // sync + boolean notDone = true; + int failCount = 0; + while (notDone) { + try { + rs = statement.executeQuery(); + notDone = false; + } catch (SQLException e) { + try { + Thread.sleep(1000); + } catch (InterruptedException e1) { + throw new PoemBugPoemException("Sleep interrupted"); + } + if (failCount > 8 ) { + throw new PreparedSQLSeriousPoemException( + statement, e); + } + } + } + } else + rs = statement.executeQuery(); token.toTidy().add(rs); return rs; } catch (SQLException e) { |