1 Reply Latest reply on Jun 27, 2011 7:50 AM by 655560

    Connecting Berkely DB in java through sqlitejdbc-v056.jar

      i am connecting berkely database through sqlitejdbc-v056.jar & i got the following error and not performing insert ,update ,delete opration

      java.sql.SQLException: database is locked
      at org.sqlite.DB.throwex(DB.java:288)
      at org.sqlite.NativeDB.prepare(Native Method)
      at org.sqlite.DB.prepare(DB.java:114)
      at org.sqlite.Stmt.executeUpdate(Stmt.java:102)
      at testdb.TestProgram.main(TestProgram.java:37)

      download jar from following link http://www.zentus.com/sqlitejdbc/

      i am using following code for performing

      import java.sql.Statement;
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.ResultSet;
      import org.sqlite.*;

      * @author dhananjay.joshi
      public class TestProgram
      public static void main(String args[])
      Connection con=null;
      Statement smt=null;
      ResultSet rs = null;

      System.out.print("Connnection req");
      con = DriverManager.getConnection("jdbc:sqlite:C:\\Prog\\Emp.db");
      smt = con.createStatement();
      System.out.println("\n Connected");
      String que = "insert into student values(2,'kiran')";
      smt.executeUpdate("insert into student values(2,'kiran');");
      System.out.print("Insert Data");
      catch(Exception e)
        • 1. Re: Connecting Berkely DB in java through sqlitejdbc-v056.jar

          1) If your application doesn't run under multi-process scenarios
          This kind of locking issue is usually caused by other progresses/applications, which still opening/writing your database. e.g.: a database shell is opening and writing the target database. So please use tools to find which processes/applications is operating on the target database unexpectedly.

          2) If your application does run under multi-process scenarios
          Your code need to catch and handle such kind of database lock exception, which is a normal event in multi-process scenarios.

          Best regards,
          Rucong Zhao
          Oracle Berkeley DB