0

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

2
  • Does it run from IDE? Commented Feb 20, 2015 at 1:33
  • Are you trying to create a new database? Or open an existing one? To create a new database, you can specify ";create=true" when you call DriverManager.getConnection(). Commented Feb 20, 2015 at 5:47

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.