简体   繁体   English

关闭 NetBeans IDE 时 Apache Derby DB 不工作

[英]Apache Derby DB not working when I close NetBeans IDE


I am a beginner to Java and Databases.我是 Java 和数据库的初学者。
Recently, i have been developing a Java Application where I am using derby database.最近,我一直在开发一个 Java 应用程序,我在其中使用了derby数据库。 When I start NetBeans and run the project it works fine.当我启动 NetBeans 并运行该项目时,它工作正常。 But when I close the IDE and run the .JAR file it does not not work.但是当我关闭 IDE 并运行 .JAR 文件时,它不起作用。 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. Netbeans 正在以联网模式为您运行 Apache Derby,并且您的应用程序正在连接到它。 When netbeans is not running, then the database is not running either, so it's not available to your application.当 netbeans 未运行时,数据库也未运行,因此它对您的应用程序不可用。

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.如果您希望您的应用程序能够在不通过网络访问数据库的情况下运行,那么您的应用程序必须更改为以嵌入模式运行 Derby。

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.如果您希望您的应用程序连接到网络版的 Derby 运行,您需要安排在您的应用程序可以连接到它的某个地方运行 Derby。

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.显然,当您连接到localhost:1527端口时,它不会运行,它以网络模式(更确切地说是客户端-服务器模式)打开,这意味着:它仅在运行 Apache Derby DB 服务器的 IDE 运行时才有效,并且所有其他服务。

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.您应该尝试在Embedded模式下运行它,即使您没有建立到 Derby 服务器的连接,它也会运行您的数据库。

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 .更简单的方式,我会说它就像一个文件到您的 java 可执行文件,它根据您提供的模式操作数据 You must try this fantastic and simple way Java, NetBeans and Derby Embedded .您必须尝试这种奇妙而简单的方式Java、NetBeans 和 Derby Embedded It will server your purpose.它将服务于您的目的。 But before you begin Embedded you must add derby.jar file to your classpath.但是在开始Embedded之前,您必须将derby.jar文件添加到您的类路径中。

Thanks!!谢谢!! Hope it helps希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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