Programmatically setting derby.system.home

You must move the databases and JavaDB (derby) db file log files to the deployment directories. The database works in the application launch directory, because JavaDB creates a folder with the database name (in my case mydb), but I want to move this directory to a subdirectory called data / create data / mydb. I can do this by calling connect:

DriverManager.getConnection("jdbc:derby:data/mydb;create=false"); 

and it works. But I would like to explicitly set the value programmatically

derby.system.home = data /
derby.stream.error.file = Log /derby.log

So, I can do:

 DriverManager.getConnection("jdbc:derby:mydb;create=false"); 

and all dbs will be in this data / dir. And the derby log file will be in /! I just can't figure it out. Anyone help? Is there a way to set these properties programmatically (because it's built-in)?

+6
java derby javadb
source share
1 answer

The documentation (Derby Developer's Guide: Setting Derby Properties) suggests something like:

 Properties p = System.getProperties(); p.setProperty("derby.system.home", "C:\databases\sample"); 

I also saw

 /* setting an attribute in a Properties object */ Properties myProps = new Properties(); myProps.put("create", "true"); Connection conn = DriverManager.getConnection("jdbc:derby:sampleDB", myProps); 
+5
source share

All Articles