db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pranav Aggarwal <pranav.aggar...@altair.com>
Subject ref: connection to derby failed
Date Fri, 09 Feb 2007 03:36:20 GMT
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?    

-- 
Thanks
Pranav Aggarwal
Altair Engineering
www.altair.com


Mime
View raw message