Hi

I've found out the hard way that the exception generated when a
database is locked has changed from 034 to 036 ("database locked" in
034 vs "database is locked" in 036). Is there a better way to handle
particular types of exception rather than just throwing SQLExceptions
with specific descriptions? For example, what about subclasses such as
SQLLockedException, SQLSyntaxException, etc? Or is this too strictly
defined by JDBC to be changed?

   Thanks

        Adam

PS at the moment, for reference the code I am currently using is:

while(done == false){
        try{
                //run it
                statement.execute(sql);
                done = true;
        }catch(SQLException e){
                if(e.toString().matches(".*database.*locked.*")){
                        //wait and retry
                        done = false;
                        try{
                                Thread.sleep(Settings.random.nextInt(1000));
                        }catch(Exception interruptException){
                                //BAD do nothing
                        }
                }
                else{
                        System.out.println("ERROR: unable to run SQL query");
                        System.out.println(sql);
                        System.out.println(e.toString());
                        StringWriter sWriter = new StringWriter();
                        e.printStackTrace(new PrintWriter(sWriter));
                        System.out.println(sWriter.getBuffer().toString()) ;
                        return;
                }
        }
}


--~--~---------~--~----~------------~-------~--~----~
Mailing List: http://groups.google.com/group/sqlitejdbc?hl=en
To unsubscribe, send email to [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to