You can set properties programmatically -- either in application code before booting the Derby driver or as a command-line option to the Java Virtual Machine (JVM) when booting the application that starts up Derby. When you set properties programmatically, these properties persist only for the duration of the application. Properties set programmatically are not written to the derby.properties file or made persistent in any other way by Derby.
You can set properties programmatically in the following ways:
You can set system-wide properties as parameters to the JVM command line when you start up the application or framework in which Derby is embedded. To do so, you typically use the -D option. For example:
java -Dderby.system.home=C:\home\Derby\ -Dderby.storage.pageSize=8192 JDBCTest
In embedded mode, your application runs in the same JVM as Derby, so you can also set system properties within an application using a Properties object before loading the Derby JDBC driver. The following example sets derby.system.home on Windows.
Properties p = System.getProperties(); p.setProperty("derby.system.home", "C:\databases\sample");