简体   繁体   中英

Apache Derby DB not working when I close NetBeans IDE


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?

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/oa 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 add derby.jar file to your classpath.

Thanks!! Hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM