CodeAngel
CodeAngel

Reputation: 579

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. 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

Upvotes: 0

Views: 1517

Answers (1)

stove
stove

Reputation: 576

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.

Upvotes: 1

Related Questions