使用嵌入式Derby数据库部署Java应用程序 [英] Deploy Java Application with Embedded Derby Database

查看:98
本文介绍了使用嵌入式Derby数据库部署Java应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Netbeans 1.8 IDE开发Java桌面应用程序时,该应用程序将使用嵌入式derby数据库存储数据.到derby数据库的连接如下.

Am developing a java desktop application using Netbeans 1.8 IDE, the application will use embedded derby database to store data. The connection to the derby database is by the following.

 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);
            }

要部署该应用程序,我将数据库添加到了Netbeans生成的dist文件夹中. 但是任何时候我运行该应用程序,它都无法连接到Wa_Poly数据库 任何建议都受到欢迎

to deploy the application , I added the database to the dist folder generated by the Netbeans. But any time I run the application , it is not able to connect to the Wa_Poly database Any suggestion is welcomed

推荐答案

在主机var中,您指定的路径与dist文件夹的路径不同.如果您将db放到dist文件夹中,那么拥有这样的东西就足够了

In host var you specified different path than to your dist folder. If you put your db to your dist folder, it should be sufficient to have something like this

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

您是否正确加载JDBC驱动程序?

Do you load JDBC driver properly?

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

请注意,为了进一步研究,最好提供更多代码.

Note that for further investigation it would be good to provide more code.

这篇关于使用嵌入式Derby数据库部署Java应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆