Hi Pranav,

In the embedded mode, a Derby database can be booted only by a single JVM (use the Network server if you want multiple applications to access the db). Looking at the error you mentioned the first thing is to *ensure *no other application (tools like 'ij') is using
(connected to) the 'mydb' while you are running you little test program.

The test program in your mail is very straight forward and I don't see why the connect should not work if the 'mydb' is present and is currently not being used by other applications.

-Rajesh

Pranav Aggarwal wrote:
Hi all,

I am new to Derby, just trying a small program which makes connection to derby DB.
Following program I have written:
import java.sql.*;
class derby_connect
{
      void connect() throws Exception
      {
              String driver="org.apache.derby.jdbc.EmbeddedDriver";
              String dbName="mydb";
              String connectionURL="jdbc:derby:"+dbName;
              Connection conn=null;
              try
              {
                      Class.forName(driver);
              }catch(java.lang.ClassNotFoundException e)
              {
                      e.printStackTrace();
              }
              try
              {
                      conn=DriverManager.getConnection(connectionURL);
                      System.out.println("Connection established!!!");
              }
              catch(Throwable e)
              {e.printStackTrace();}
              finally {conn.close();}
      }//end of connect()
      public static void main(String args[]) throws Exception
      {
              derby_connect dc=new derby_connect();
              dc.connect();
      }
}//end of class
The program resides in same directory where DB is residing. Now when I run, I get the following error:

$ java derby_connect
java.sql.SQLException: Failed to start database 'mydb', see the next exception for details. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown Source) at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
      at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
      at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
      at java.sql.DriverManager.getConnection(DriverManager.java:582)
      at java.sql.DriverManager.getConnection(DriverManager.java:207)
      at derby_connect.connect(derby_connect.java:21)
      at derby_connect.main(derby_connect.java:32)
Caused by: java.sql.SQLException: Failed to start database 'mydb', see the next exception for details. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
      ... 16 more
Exception in thread "main" java.lang.NullPointerException
      at derby_connect.connect(derby_connect.java:26)
      at derby_connect.main(derby_connect.java:32)
Can any one help me with this?

Reply via email to