Java DB

Apache Derby

Derby Developer's Guide

Derby Getting Started
Derby Reference Manual
Derby Developer's Guide
Derby Performance Tuning
Derby Server and Admin Guide
Derby Tools and Utilities
Derby Developer's Guide
-After installing
-Upgrades
-JDBC applications and Derby basics
-Application development overview
-Derby embedded basics
-Derby JDBC driver
-Derby JDBC database connection URL
-Derby system
-A Derby database
-Connecting to databases
-Working with the database connection URL attributes
-Using in-memory databases
-Working with Derby properties
-Deploying Derby applications
-Deployment issues
-Creating Derby databases for read-only use
-Loading classes from a database
-Derby server-side programming
-Programming database-side JDBC routines
-Programming trigger actions
-Programming Derby-style table functions
-Programming user-defined types
-Controlling Derby application behavior
-The JDBC connection and transaction model
-Result set and cursor mechanisms
-Locking, concurrency, and isolation
-Working with multiple connections to a single database
-Working with multiple threads sharing a single connection
-Working with database threads in an embedded environment
-Working with Derby SQLExceptions in an application
-Using Derby as a J2EE resource manager
-Derby and Security
-Configuring security for your environment
-Working with user authentication
-Users and authorization identifiers
-User authorizations
-Encrypting databases on disk
-Signed jar files
-Notes on the Derby security features
-User authentication and authorization examples
-Running Derby under a security manager
-Developing tools and using Derby with an IDE
-SQL tips
-Localizing Derby
-Derby and standards

 

Getting a DataSource

Normally, you can simply work with the interfaces for javax.sql.DataSource, javax.sql.ConnectionPoolDataSource, and javax.sql.XADataSource, as shown in the following examples.

// If your application is running on the Java SE 6 platform,
// and if you would like to call DataSource methods specific 
// to the JDBC 4 API (for example, isWrapperFor), use the
// JDBC 4 variants of these classes:
//
//   org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource40
//   org.apache.derby.jdbc.EmbeddedDataSource40
//   org.apache.derby.jdbc.EmbeddedXADataSource40
//
import org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource;
import org.apache.derby.jdbc.EmbeddedDataSource;
import org.apache.derby.jdbc.EmbeddedXADataSource; 

javax.sql.ConnectionPoolDataSource cpds = new EmbeddedConnectionPoolDataSource(); 
javax.sql.DataSource ds = new EmbeddedDataSource(); 
javax.sql.XADataSource xads = new EmbeddedXADataSource();

Derby provides six properties for a DataSource. These properties are in org.apache.derby.jdbc.EmbeddedDataSource. They are:

  • DatabaseName

    This mandatory property must be set. It identifies which database to access. To access a database named wombat located at /local1/db/wombat, call setDatabaseName("/local1/db/wombat") on the data source object.

  • CreateDatabase

    Optional. Sets a property to create a database the next time the getConnection method of a data source object is called. The string createString is always "create" (or possibly null). (Use the method setDatabaseName() to define the name of the database.)

  • ShutdownDatabase

    Optional. Sets a property to shut down a database. The string shutDownString is always "shutdown" (or possibly null). Shuts down the database the next time the getConnection method of a data source object is called.

  • DataSourceName

    Optional. Name for ConnectionPoolDataSource or XADataSource. Not used by the data source object. Used for informational purposes only.

  • Description

    Optional. Description of the data source. Not used by the data source object. Used for informational purposes only.

  • connectionAttributes

    Optional. Connection attributes specific to Derby. See the Derby Reference Manual for a more information about the attributes.

 

javadb@jdbcurl.com