Results 1 to 6 of 6
  1. #1
    newbiejava is offline Senior Member
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    0

    Default connect to derby thrown SQLException

    Hello The Expert,

    I am trying to connect to derby .. but it thrown SQLException, what I missed?
    please help ..

    thanks & regards

    Java Code:
    private void connectDerby() {
            try {
                String driver = "org.apache.derby.jdbc.EmbeddedDriver";
                String dbName = "smdr";
                String connectionURL = "jdbc:derby:" + dbName + ";create=true";
                String sql = "select * from app.smdrs";
                Class.forName(driver);
                Connection conn;
                conn = DriverManager.getConnection(connectionURL);
                Statement st = conn.createStatement();
                ResultSet rs = st.executeQuery(sql);
                while (rs.next()) {
                    System.out.println(" Name: " + rs.getString("model"));
                }
                rs.close();
            } catch (Exception ex) {
                cls1.msgBox(this, ex.toString(), "TEST", Main.MESSAGE_ERROR);
            }
        }

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Do
    Java Code:
     catch (Exception ex) {
          ex.printStackTrace();
     }
    To see the exact problem that occured.
    Last edited by r035198x; 01-20-2010 at 10:17 AM.

  3. #3
    newbiejava is offline Senior Member
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    0

    Unhappy

    Found the following, but no idea what to do?..

    Java Code:
    java.sql.SQLException: Failed to start database 'smdr', 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.seeNextException(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 netcomm2.FrmConfig.connectDerby(FrmConfig.java:1233)
            at netcomm2.FrmConfig.<init>(FrmConfig.java:33)
            at netcomm2.Main$2.actionPerformed(Main.java:69)
            at java.awt.MenuItem.processActionEvent(MenuItem.java:627)
            at java.awt.MenuItem.processEvent(MenuItem.java:586)
            at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:317)
            at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:305)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:602)
            at 
    java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at 
    java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at 
    java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at 
    java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at 
    java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Caused by: java.sql.SQLException: Failed to start database 'smdr', 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)
            ... 26 more
    Caused by: java.sql.SQLException: Another instance of Derby may have already 
    booted the database C:\Project\Matrix .NET\Billing\NetComm2\smdr.
            at 
    org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown 
    Source)
            at 
    org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown 
    Source)
            at 
    org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown 
    Source)
            at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown 
    Source)
            ... 23 more
    Caused by: ERROR XSDB6: Another instance of Derby may have already booted 
    the database C:\Project\Matrix .NET\Billing\NetComm2\smdr.
            at 
    org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
            at 
    org.apache.derby.impl.store.raw.data.BaseDataFileFactory.privGetJBMSLockOnDB(Unknown 
    Source)
            at 
    org.apache.derby.impl.store.raw.data.BaseDataFileFactory.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at 
    org.apache.derby.impl.store.raw.data.BaseDataFileFactory.getJBMSLockOnDB(Unknown 
    Source)
            at 
    org.apache.derby.impl.store.raw.data.BaseDataFileFactory.boot(Unknown 
    Source)
            at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown 
    Source)
            at 
    org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
            at 
    org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown 
    Source)
            at 
    org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown 
    Source)
            at org.apache.derby.impl.store.raw.RawStore.boot(Unknown Source)
            at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown 
    Source)
            at 
    org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
            at 
    org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown 
    Source)
            at 
    org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown 
    Source)
            at org.apache.derby.impl.store.access.RAMAccessManager.boot(Unknown 
    Source)
            at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown 
    Source)
            at 
    org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
            at 
    org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown 
    Source)
            at 
    org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown 
    Source)
            at org.apache.derby.impl.db.BasicDatabase.bootStore(Unknown Source)
            at org.apache.derby.impl.db.BasicDatabase.boot(Unknown Source)
            at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown 
    Source)
            at 
    org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
            at 
    org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown 
    Source)
            at 
    org.apache.derby.impl.services.monitor.BaseMonitor.startProviderService(Unknown 
    Source)
            at 
    org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(Unknown 
    Source)
            at 
    org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(Unknown 
    Source)
            at 
    org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Unknown 
    Source)
            ... 23 more

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Only one JVM can access an embedded DB at once, so you seemingly have this same DB open in another JVM when you start your web app. In any case, if you're using a web app, then setup a coneection pool and use it properly.

  5. #5
    newbiejava is offline Senior Member
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    0

    Default

    thanks, could you please advise how to set connection pool ? ..

  6. #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

Similar Threads

  1. Replies: 0
    Last Post: 06-08-2009, 09:59 PM
  2. using if in derby
    By suhaib1thariq in forum JDBC
    Replies: 0
    Last Post: 01-25-2009, 04:46 AM
  3. [SOLVED] Unable to connect to Derby from jsp pages
    By smartboy3k in forum New To Java
    Replies: 1
    Last Post: 12-30-2008, 05:27 PM
  4. Which exception is thrown.....
    By money123 in forum New To Java
    Replies: 1
    Last Post: 07-30-2007, 03:41 PM
  5. Replies: 1
    Last Post: 07-23-2007, 11:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •