0
votes

I read a lot of posts like: querying embedded database in netbeans using derby

But still I'm having trouble to understand embedded databases.

1) I create a Derby database on Netbeans and I can create tables, link the database to a form and submit the data and update the records with no problem.

2) The problem arises when I want to make the program portable. I apply Clean and Build, then copy the dist folder and also copy the libraries, database, etc ... but when running the program does not recognize the database

3) I read in several places that it is appropriate that the database is created by code using something like

String host = "jdbc: derby: // localhost: 1527 / EmployeesCreateTrue; create = true"

and not creating the database on Netbeans Service...

If I do this procedure with code the database is created but it does not appear or does not allow me to connect from NetBeans and I wish I could fix it to create tables from NetBeans and not from code.

4) I read manuals "how to import a database from Derby to NetBeans" and it doesn't work...

Question: What is the best way to create a database, tables and connect to NetBeans for the final application to be easily portable?

1) Create the database on Netbeans with the wizzard?

or

2) Just plain code on the application?

3

3 Answers

0
votes

I don't understand precisely what you mean by "the database is created but it does not appear."

I think if you were to explain that precisely, the community could probably help you.

There are three common reasons for "table does not exist" when you think you've created the tables; I've explained those cases in this answer: Is it necessary to create tables each time you connect the derby database?

Please let us know more information about your situation so that we can help you better understand the behavior of your application.

0
votes

I'm not 100% sure if this is your problem, but a lot of problems people seem to have with Netbeans and Derby seems to come from the fact that they don't set derby.system.home explicitly. When you don't, Derby stores databases in the current directory, and that is likely different when working in the IDE, either in the Services tab, or your own code, than when you execute your app's jar as a standalone program. So the advice (which you will also find in the manual) is: always set derby.system.home. An alternative would be to use full paths to the databases, but that rarely works well for a real application that is deployed on different machines.

0
votes

I had the same problem --had the derby db in the services but the netbeans coded programs didn't access it. I solved it by adding the derby database (copy paste) to the package in the Files section. I use Windows 7. Once I did that, I was able use multiple tables (before netbeans just ignored secondary tables and only allowed me to use the primary table).