ij.dataSource property


The ij.dataSource property specifies the datasource to be used to access the database. When specifying a datasource, Derby does not use the DriverManager mechanism to establish connections.


To establish a connection using ij.dataSource, you need to set the ij.dataSource.databaseName property. If you want to create the database, specify the ij.dataSource.createDatabase property as well.

Example 1

In the following example, ij connects to a database named sample using an EmbeddedDataSource. The sample database is created if it does not already exist.

# If your application runs on JDK 1.6 or higher, then you should
# specify the JDBC4 variant of this DataSource:
# org.apache.derby.jdbc.EmbeddedDataSource40.
java -Dij.dataSource=org.apache.derby.jdbc.EmbeddedDataSource
-Dij.dataSource.databaseName=sample -Dij.dataSource.createDatabase=create
ij version 10.3 
* = current connection

Example 2

In the following example, ij starts using an EmbeddedSimpleDataSource, then creates a database named smalldb using the connect command, specifying ;create=true to create the database if it does not already exist.

# If your application runs with a jvm supporting JSR169, you cannot use
# org.apache.derby.jdbc.EmbeddedDataSource, but you can use 
# org.apache.derby.jdbc.EmbeddedSimpleDataSource instead.
# Because specifying a protocol would automatically attempt to load a driver,
# when using ij.dataSource you should omit the protocol on connect.
# This is especially relevant with JSR169 because java.sql.Driver is not supported.
java -Dij.dataSource=org.apache.derby.jdbc.EmbeddedSimpleDataSource
ij version 10.3 
ij> connect 'smalldb;create=true'; 
For more information about DataSources, refer to the JDBC documentation and "Using Derby as a J2EE Resource Manager" in the Java DB Developer's Guide.
Related reference
ij.connection.connectionName property
ij.database property
ij.driver property
ij.exceptionTrace property
ij.maximumDisplayWidth property
ij.outfile property
ij.password property
ij.protocol property
ij.protocol.protocolName property
ij.showErrorCode property
ij.showNoConnectionsAtStart property
ij.showNoCountForSelect property
ij.URLCheck property
ij.user property
derby.ui.codeset property