# ij.dataSource property

The `ij.dataSource` property specifies the datasource to be used to access the database.

When specifying a datasource, `ij` does not use the DriverManager mechanism to establish connections.

## Syntax

When you set the `ij.dataSource` property, `ij` will automatically try to connect to a database. To establish a connection to a specific database using `ij.dataSource`, set the `ij.dataSource.databaseName` property. If you do not set this property, `ij` will start with an error. If you want to create the database, specify the `ij.dataSource.createDatabase` property as well as `ij.dataSource.databaseName`. Do not specify `ij.protocol` when setting `ij.dataSource`, as that would activate the DriverManager mechanism.

    ij.dataSource=datasourceClassName
    ij.dataSource.databaseName=databaseName
    [ij.dataSource.createDatabase=create]

If you do not specify `ij.dataSource.databaseName` and get an error indicating no database was found, you can still connect to a database by using `ij`'s `Connect` command. You should not specify the protocol (for example, `jdbc:derby:`) in the `connect` command when using `ij.dataSource`.

## Example

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.

    java -Dij.dataSource=org.apache.derby.jdbc.EmbeddedDataSource \
    -Dij.dataSource.databaseName=sample \
    -Dij.dataSource.createDatabase=create org.apache.derby.tools.ij
    ij version 10.15
    CONNECTION0*
    * = current connection
    ij>

## See also

For more information about DataSources, refer to the JDBC documentation in the Derby API documentation and to "JDBC reference" in the Derby Reference Manual, and to "Using Derby as a Java EE Resource Manager" in the Derby Developer's Guide.

Parent topic: ij properties reference
Related reference
ij.connection.connectionName property
ij.database 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
derby.ui.locale property