Changing the system-wide properties programmatically system propertiessetting on command line propertiessetting using a Properties object system propertiessetting in a Properties object

You can set properties programmatically -- either in application code before booting the driver or as a command-line option to the Java Virtual Machine (JVM) when booting the application that starts up . 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 .

Setting properties programmatically works only for the application that starts up ; for example, for an application in an embedded environment or for the application server that starts up a server product. It does not work for client applications connecting to a server that is running.

You can set properties programmatically in the following ways:

As a parameter to the JVM command line

You can set system-wide properties as parameters to the JVM command line when you start up the application or framework in which is embedded. To do so, you typically use the -D option. For example:

java -Dderby.system.home=C:\home\\ -Dderby.storage.pageSize=8192 JDBCTest
Using a Properties object within an application or statement

In embedded mode, your application runs in the same JVM as , so you can also set system properties within an application using a Properties object before loading the JDBC driver. The following example sets derby.system.home on Windows.

Properties p = System.getProperties(); p.setProperty("derby.system.home", "C:\databases\sample"); If you pass in a Properties object as an argument to the DriverManager.getConnection call when connecting to a database, those properties are used as database connection URL attributes, not as properties of the type discussed in this section. For more information, see and as well as the .