Reputation: 147
So I'm new to working with Java databases and I've settled on using Apache Derby. I have it installed on my system and have included the derby.jar in the project buildpath. However, I need this project to be portable (including from Windows to OSX/UNIX) so that the database can be initialized and fully accessed for updating and reading on a device other than my machine.
So my question is, how do I make this happen? Is including the derby.jar file enough or do I need to do something like initialize a database within the project file system or something else? Do I need to specify a certain write location in a class within the project? If it's helpful, I'm using Eclipse IDE.
Thanks for any help!
Upvotes: 1
Views: 393
Reputation: 147
So after some thorough reading I found my own solution, at least in theory (I've not yet finished the project build to try it out). Use this in a Data Access Object (DAO).
As per John O'Conner:
private void setDBSystemDir() {
/* Decide on the db system directory: <userhome>/DerbyDB/DBName/ */
String userHomeDir = System.getProperty("user.home", ".");
String systemDir = userHomeDir + "/DerbyDB/DBName";
// Set the db system directory.
System.setProperty("derby.system.home", systemDir);
}
Upvotes: 1