I am on windows 7 and this is my test code

try
         {
             Statement stat = mconn.createStatement();
             stat.execute(sql);
             resultSet = stat.getResultSet();
             mconn.close();
             break;
         }
         catch (SQLException e)
         {

             retryCount++;
             switch(e.getErrorCode())
             {
             case SQLITE_BUSY :
                 /* falls through */
             case SQLITE_LOCKED :
                 /* falls through */
             case SQLITE_PROTOCOL :
                 if ( mlogger != null )
                 {
                     mlogger.logWarn(0, "getResultSet() ", 
String.format("%s, Error code : %d", e.getMessage(),e.getErrorCode()));
                 }
                 /*
                  * swallow the exception and retry once again
                  */
                 break;

             default :
                 if ( mlogger != null )
                 {
                     mlogger.logError(0,"getResultSet() 
",String.format("Insert query returned error: %s Error code : %d",
                         e.getMessage(), e.getErrorCode()));
                 }
                 /*
                  * The old driver was throwing SQLException with 
message "database locked" or "database is locked" with
                  * error code 0. Even though we moved to new driver, we 
may need to have a fall back for a while.
                  */
                 if (!("database 
locked".equalsIgnoreCase(e.getMessage()) || "database is 
locked".equalsIgnoreCase(e.getMessage())))
                 {
                     return null;
                 }
                 /*
                  * swallow the exception and retry once again
                  */

             }

         }

This is my connection code

try {
         Class.forName("org.sqlite.JDBC");
         mconn = DriverManager.getConnection("jdbc:sqlite:"    + 
connectionString);
     } catch (SQLException e) {
         if ( mlogger != null ) mlogger.logError(0, "openConnection() ", 
e.getMessage());
         e.printStackTrace();
         return false;
     } catch (Exception e) {
         if ( mlogger != null ) mlogger.logError(0, "openConnection() ", 
e.getMessage());
         e.printStackTrace();
   }

I tried this test using the driver from xerial and also from sqlite. 
Both of them are returning the wrong error codes.  Let me know if any 
further information helps.

Thanks
Sridhar



On 08-06-2011 20:26, Martin.Engelschalk wrote:
> Hello Sridhar,
>
> please tell us more: what interface are you using? what OS?
> SQLException is not a part of the sqlite library, so obviously you use 
> an additional layer.
>
> Martin
>
> Am 08.06.2011 16:44, schrieb Sridhar Polavarapu:
>> Appreciate if anyone can help me.
>>
>> Thanks
>> Sridhar
>>
>> On 08-06-2011 16:16, Sridhar Polavarapu wrote:
>>> Hi
>>>
>>> I am using getErrorCode() of SQLException to see if the exception is
>>> due to any database lock. I all the time get Errorcode to be 0 even
>>> though the getMessage is returning different messages. Can anyone let
>>> me know if there is some thing that i need to do to get the error
>>> codes correctly ?
>>>
>>> Thanks
>>> Sridhar
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to