Reputation: 35
I created a java swing application with apache derby database. I want to know how can i do the following things.
The first time the application is double-clicked by a user, that finds a suitable location for the Derby database on the user's machine, creates the database and defines all the tables, views, etc and loads any initial data. Then, on subsequent runs of the application, it will be able to re-open the database and continue using it.
Upvotes: 2
Views: 566
Reputation: 748
Following shall start derby database service on default port (1527) on localhost
NetworkServerControl obj= new NetworkServerControl();
obj.start(null);
Use dburl with 'create=true', i.e.
jdbc:derby://localhost:1527/macdb;create=true
Above shall make db dir (macdb), same name as service name on current dir.
Upvotes: 0
Reputation: 347204
user.home
property from System.getProperty
which will return you the user's home directory as the main path for the database. On Windows, I would recommend using {user.home}\AppData\Remote\{You application name}
as a base pathUpvotes: 3