Deploy Java Application with Embedded Derby Database

…衆ロ難τιáo~ 提交于 2019-12-13 02:48:01

问题


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

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


回答1:


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";

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.



来源:https://stackoverflow.com/questions/28620182/deploy-java-application-with-embedded-derby-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!