I have nearly finished a project developing a simple image catalogue application using Java and Netbeans.
I have only now realised that my database is not embedded so when I create the JAR file and try to run it (external to Netbenas) i get an error (error connecting to localhost).
This is the code at present that connects to the database. All works fine when run in Netbeans.
//conect to database
String host = "jdbc:derby://localhost:1527/Catalogue";
con = DriverManager.getConnection(host);
My question is (and I can't seem to find a simple solution) is there a way to just create a new embedded DB with the same name and table and rows etc and then just adjust the code so when i run the JAR file externally to Netbeans all will work OK?
I am imagining the code will be something like:
String host = "jdbc:derby:'path to db'/Catalogue;
Am I on the right track? I have tried this (I think) but it does not seem to work…
Thanks for any assistance
<<<<<< UPDATE >>>>>>>
I have now created an embedded database and created a table (named photos) with exactly the same details as my original (non-embedded) database.
I have changed the connection in the code to be:
String host = "jdbc:derby:catalogueEmbed;create=true";
Now when I run the program in Netbeans it says: "Table/view PHOTOS does not exist"
Do I need to run and sql statement in my code to create the table and row data?
Thanks for any assistance