I am a beginner to Java and Databases.
Recently, i have been developing a Java Application where I am using derby
database. When I start NetBeans and run the project it works fine. But when I close the IDE and run the .JAR file it does not not work. Can anybody tell me the reason behind it?
Apache Derby DB not working when I close NetBeans IDE
691 views Asked by Dipen Ahir At
2
There are 2 answers
0
On
Netbeans is running Apache Derby for you in a networked mode, and your application is connecting to it. When netbeans is not running, then the database is not running either, so it's not available to your application.
If you want your application to run w/o a being able to reach a database over a network, your application must be changed to run Derby in embedded mode.
If you want your application to run connected to a networked version of Derby, you will need to arrange to run Derby somewhere that your application can connect to it.
Obviously it will not run as when you connect to the
localhost:1527
port, it opens in Network mode (more exactly a client-server mode) which means : it will only work when the IDE is running which runs the Apache Derby DB Server and all other services.You should try running it in
Embedded
Mode which will run your database even if you are not establishing a connection to the Derby server.In a more simpler way I would say that it acts just like a file to your java executable, which manipulates data based on the schema you provide. You must try this fantastic and simple way Java, NetBeans and Derby Embedded. It will server your purpose. But before you begin
Embedded
you must addderby.jar
file to your classpath.Thanks!! Hope it helps