0

I am trying to embed a Derby DB in my application using the following code to connect to the database:

                String host = "jdbc:derby:PlayerScores";
                String uName = "user1";
                String uPass = "pass123";

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

                Connection conn = DriverManager.getConnection(host, uName, uPass);

When I test the application and try save the data, the following message comes up:

java.sql.SQLException: Database 'PlayerScores' not found

I have checked my libraries and already have the derby.jarand the derbyclient.jarfiles in place.

I have checked my database name and it is correct.

How can I try correct this problem?

9
  • How are you running your application?? From the IDE? Are you using Windows or Linux?? Commented Jun 23, 2016 at 18:09
  • Yes I am running it from the IDE just to test the code before testing it on another computer Commented Jun 23, 2016 at 18:11
  • try String host = "jdbc:derby:PlayerScores;create=true"; Commented Jun 23, 2016 at 18:12
  • Have you defined a system directory via the system property 'derby.system.home' and does your database live in that directory? Commented Jun 23, 2016 at 18:12
  • @wero I read that statement will create the db, but it's already created. So is that statement still worth trying? Commented Jun 23, 2016 at 18:16

1 Answer 1

3

Try to define an absolute path for your database... Example:

String host = "jdbc:derby:/my/database/path/PlayerScores;create=true";

See this link for more examples...

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

2 Comments

But won't this cause a problem when I try run the application on a different computer with a different file path?
Yes, so you have to make your application configurable (through commnad line parameters or property files)...

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.