Java DB

Apache Derby

Derby Tools and Utilities Guide

Derby Getting Started
Derby Reference Manual
Derby Developer's Guide
Derby Performance Tuning
Derby Server and Admin Guide
Derby Tools and Utilities
Derby Tools and Utilities
-Copyright
-License
-About this guide
-What are the Derby tools and utilities?
-Using ij
-ij properties reference
-ij commands and errors reference
-ij commands
-Absolute command
-After Last command
-Async command
-Autocommit command
-Before First command
-Close command
-Commit command
-Connect command
-Describe command
-Disconnect command
-Driver command
-Elapsedtime command
-Execute command
-Exit command
-First command
-Get Cursor command
-Get Scroll Insensitive Cursor command
-Help command
-Last command
-LocalizedDisplay command
-MaximumDisplayWidth command
-Next command
-Prepare command
-Previous command
-Protocol command
-Readonly command
-Relative command
-Remove command
-Rollback command
-Run command
-Set Connection command
-Show command
-Wait For command
-Syntax for comments in ij commands
-Syntax for identifiers in ij commands
-Syntax for strings in ij commands
-ij errors
-Using the bulk import and export procedures
-Storing jar files in a database
-sysinfo
-dblook
-SignatureChecker
-Trademarks

 

ij.dataSource property

Function

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=datasource class name
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 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.
# If your application runs with a jvm supporting JSR169, you cannot use
# org.apache.derby.jdbc.EmbeddedDataSource, instead, use: 
# org.apache.derby.jdbc.EmbeddedSimpleDataSource.
#
java -Dij.dataSource=org.apache.derby.jdbc.EmbeddedDataSource
-Dij.dataSource.databaseName=sample -Dij.dataSource.createDatabase=create
  org.apache.derby.tools.ij
ij version 10.6 
CONNECTION0*
* = current connection
ij> 

Example 2

In the following example, ij starts using an EmbeddedSimpleDataSource, without specifying ij.dataSource.databaseName. This results in an error indicating no database was found. After the error, the connect command is used to create and connect to a database named smalldb.

#
# Start ij using EmbeddedSimpleDataSource
#
java -Dij.dataSource=org.apache.derby.jdbc.EmbeddedSimpleDataSource
  org.apache.derby.tools.ij 
ERROR XJ004: Database '' not found.
ij version 10.6 
ij> connect 'smalldb;create=true'; 
ij> 
For more information about DataSources, refer to the JDBC documentation and "Using Derby as a J2EE Resource Manager" in the Derby Developer's Guide.
 

javadb@jdbcurl.com