Search code examples
eclipsetomcatderby

accessing derby database from eclipse and ij simultaneously


I am developing an dynamic web project in eclipse which requires me to connect to a database and display the fields that I have chosen.

I have created a database named javadb. I am able to access the javadb from ij scripting tool and the eclipse IDE individually but not from both at a time. When I deploy my web app on tomcat server and run the application which is using the database javadb and when I try to connect to the database through the ij tool using the command connect 'jdbc:derby:javadb';
the error shown is

ERROR XJ040: Failed to start database 'javadb' with class loader sun.misc.Launcher$AppClassLoader@74b10b, see the next exception for details.
ERROR XSDB6: Another instance of Derby may have already booted the database /home/computer/javadb.

I am start the apache derby network server using the command

java -jar $DERBY_HOME/lib/derbyrun.jar server start

I am only able to access the javadb only after shutting down the server and restarting it.

I am using Eclipse Kepler , Apache derby 10.10 to create database, Apache tomcat 7 as server. Operating system Ubuntu 12.04

Can anyone please help me out with this problem.


Solution

  • In the embedded configuration, a Derby database can only be accessed by one Java application at a time.

    In order to have multiple applications accessing the same Derby database simultaneously, you need to run Derby in a client-server configuration, and ensure that a Derby server is running.

    Other than deploying the Derby server, the only other changes you have to make are to change your connection URL and your JDBC class name.

    Here's some documentation: http://db.apache.org/derby/docs/10.10/adminguide/cadminov17524.html and http://db.apache.org/derby/docs/10.10/adminguide/cadminov825266.html