简体   繁体   English

使用嵌入式Derby数据库部署Java应用程序

[英]Deploy Java Application with Embedded Derby Database

Am developing a java desktop application using Netbeans 1.8 IDE, the application will use embedded derby database to store data. 我正在使用Netbeans 1.8 IDE开发一个Java桌面应用程序,该应用程序将使用嵌入式derby数据库来存储数据。 The connection to the derby database is by the following. 与derby数据库的连接如下。

 final String host = "jdbc:derby:C:\\Users\\Faisal\\.netbeans- 
 derby\\Wa_Poly";
 final String uName = "APP";
 final String uPass = "12345"; 

the following code snippet is used to connect to the database. 以下代码段用于连接到数据库。

try (Connection con = DriverManager.getConnection(host, uName, uPass)) {
        try (Statement pstm = 
          con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,  
          ResultSet.CONCUR_UPDATABLE)) {
            try (ResultSet rslt = pstm.executeQuery(newRowSQL + sortby)) {
                bd = getData(rslt);
            }

to deploy the application , I added the database to the dist folder generated by the Netbeans. 为了部署应用程序,我将数据库添加到Netbeans生成的dist文件夹中。 But any time I run the application , it is not able to connect to the Wa_Poly database Any suggestion is welcomed 但是每次运行应用程序时,它都无法连接到Wa_Poly数据库。欢迎任何建议

In host var you specified different path than to your dist folder. 在host var中,您指定的路径与dist文件夹不同。 If you put your db to your dist folder, it should be sufficient to have something like this 如果你将你的数据库放到你的dist文件夹中,那么这样就足够了

final String host = "jdbc:derby:Wa_Poly";

Do you load JDBC driver properly? 你正确加载JDBC驱动程序吗?

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

Note that for further investigation it would be good to provide more code. 请注意,为了进一步调查,最好提供更多代码。

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

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