I am trying to change my database(s) from network to embedded.

I believe that the driver is working and has found the database requested with the following code:

        try {
            // connect method - embedded driver
            String dbURL1 = "jdbc:derby:Databases/Armor";
            Connection conn1 = DriverManager.getConnection(dbURL1);
            if (conn1 != null) {
                System.out.println("Connected to database #1");
            }
        }catch (SQLException ex) {
            ex.printStackTrace();
        }

I ran the program without any drivers connected to it in netbeans. I am getting the following errors:

run:
java.sql.SQLException: Failed to start database 'Databases/Armor' with class loader sun.misc.Launcher$AppClassLoader@35ce36, 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 interactive.character.sheet.Main.<init>(Main.java:96)
    at interactive.character.sheet.Main$48.run(Main.java:3463)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:646)
    at java.awt.EventQueue.access$000(EventQueue.java:84)
    at java.awt.EventQueue$1.run(EventQueue.java:607)
    at java.awt.EventQueue$1.run(EventQueue.java:605)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:616)
    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 'Databases/Armor' with class loader sun.misc.Launcher$AppClassLoader@35ce36, 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)
    ... 28 more
Caused by: java.sql.SQLException: Database at C:\Users\Mike\Documents\NetBeansProjects\Interactive Character Sheet\Databases\Armor has an incompatible format with the current version of the software.  The database was created by or upgraded by version 10.9.
    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)
    ... 25 more
Caused by: ERROR XSLAN: Database at C:\Users\Mike\Documents\NetBeansProjects\Interactive Character Sheet\Databases\Armor has an incompatible format with the current version of the software.  The database was created by or upgraded by version 10.9.
    at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
    at org.apache.derby.impl.store.raw.log.LogToFile.readControlFile(Unknown Source)
    at org.apache.derby.impl.store.raw.log.LogToFile.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.data.BaseDataFileFactory.bootLogFactory(Unknown Source)
    at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.setRawStoreFactory(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)
    ... 25 more

Is there something wrong with the code, or the previously created database?

the program works perfectly well with the network or client driver. If I interpret this correctly, that the driver I am using is either incompatable, or out of date (old version).

Ideas or suggestions?

Go to services. Right click on your database and choose connect.

Aaaa right.... I know how to connect to a database.

If you did not notice, I am getting an error saying that the database has a incompatable format and was created/modified by a different version of the driver that is trying to access it. I have confirmed that the version of the selected driver is correct for the database.

This error only occurs when I try to access it in embedded mode, and works good in client mode.

Is there a way that I can have the program act as its own database server, and remain in client mode or solving this embedded access problem.

I have been attempting to change this from client to embedded mode for 4 weeks now to no avail and getting frustrated considering that the program needs to access 14 different databases and the only thing preventing completion & exporting it into a standalone software application is this problem.

Ideas, suggestions, places to check to ensure proper settings, almost anything now would help.....

Thanks from a frustrated old man.......

The error means that the version used to create the db file isn't the same as the derby JAR version you are using to access it. Take a look at this thread and see if updating the JAR file helps. Also, this topic in the Netbeans forum if the previous one doesn't work for you.

To check if you are using the same JAR files in both the modes, dump the class files loaded by the JVM when running the client/embedded code. In both cases, you should see the JAR location from which the Derby class files are getting loaded. Given the error, they should point to different locations. Pass the -verbose:class switch to the JVM before starting it.

I was suspecting this..... with all the databases, and so far I have discovered at least 2 different versions were used in creating the 15 databases. I am in the process of rebuilding ALL the databases to ensure that they have the same version. Will repost if this is successful. thanks.

I deleted one database and recreated it with driver 10.10.1.1 and confirmed that is so.
In netbeans 7.1.2 services tab made sure that the embedded driver is set to that driver version db-derby-10.10.1.1-bin\lib\derby.jar for org.apache.derby.jdbc.EmbeddedDriver

I am still getting the error:
has an incompatible format with the current version of the software. The database was created by or upgraded by version 10.10.

This is the driver that I think it should be using because it is the same in both the Java DB /properties, and Drivers (java DB (Embedded) /customized).

Does Netbeans have another place besides the services tab that determines which driver that will be used such as a global setting.

I don't really use Netbeans but as mentioned in my previous post, you need to run the code in both client and embeddable mode with verbose class loading enabled so find out which drivers are getting used. If what you say is correct, then we should see the same JAR file getting loading in both the scenarios.

The solution that I found for my problem is that I had originally created the database in netbeans itself. What I should have done that upon initial design of the program that will use the databases, create the database FROM WITHIN THE ACTUAL PROGRAM ITSELF, NOT NETBEANS.

            String dbURL5 = "jdbc:derby:Databases\\Armor; create=true";
            Connection conn5 = DriverManager.getConnection(dbURL5);
            if (conn5 != null) {System.out.println("Connected to database - Armor");
            }

Be sure when you connect to the database (when it has NOT yet been defined or created), use the create=true. This creates and ensures that the database and the driver will work with each other. After this initial creation, you can use netbeans to define the record structure as well as the data contained inside.

It took a while to do (15 databases, some very large), but now it works as intended.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.