org.apache.derby.jdbc
Class EmbeddedDataSource40

java.lang.Object
  extended by org.apache.derby.jdbc.EmbeddedBaseDataSource
      extended by org.apache.derby.jdbc.ReferenceableDataSource
          extended by org.apache.derby.jdbc.EmbeddedDataSource
              extended by org.apache.derby.jdbc.EmbeddedDataSource40
All Implemented Interfaces:
java.io.Serializable, java.sql.Wrapper, javax.naming.Referenceable, javax.naming.spi.ObjectFactory, javax.sql.CommonDataSource, javax.sql.DataSource, EmbeddedDataSourceInterface

public class EmbeddedDataSource40
extends EmbeddedDataSource
implements javax.sql.DataSource

This datasource is suitable for an application using embedded Derby, running on the following platforms:

Use BasicEmbeddedDataSource40 if your application runs on Java 8 Compact Profile 2.

Use EmbeddedDataSource if your application runs on the following platforms:

EmbeddedDataSource40 is a DataSource implementation.

A DataSource is a factory for Connection objects. An object that implements the DataSource interface will typically be registered with a JNDI service provider.

The following is a list of properties that can be set on a Derby DataSource object:

Standard DataSource properties (from JDBC 3.0 specification).


Derby specific DataSource properties.

Examples.

This is an example of setting a property directly using Derby's EmbeddedDataSource40 object. This code is typically written by a system integrator :

 

 import org.apache.derby.jdbc.*;

 // dbname is the database name
 // if create is true, create the database if necessary
 javax.sql.DataSource makeDataSource (String dbname, boolean create)
        throws Throwable 
 { 
        EmbeddedDataSource40 ds = new EmbeddedDataSource40(); 
        ds.setDatabaseName(dbname);

        if (create)
                ds.setCreateDatabase("create");
   
        return ds;
 }
        

Example of setting properties thru reflection. This code is typically generated by tools or written by a system integrator:

        
 javax.sql.DataSource makeDataSource(String dbname) 
        throws Throwable 
 {
        Class[] parameter = new Class[1];
        parameter[0] = dbname.getClass();
        DataSource ds =  new EmbeddedDataSource40();
        Class cl = ds.getClass();

        Method setName = cl.getMethod("setDatabaseName", parameter);
        Object[] arg = new Object[1];
        arg[0] = dbname;
        setName.invoke(ds, arg);

        return ds;
 }
        

Example on how to register a data source object with a JNDI naming service.

 DataSource ds = makeDataSource("mydb");
 Context ctx = new InitialContext();
 ctx.bind("jdbc/MyDB", ds);
        

Example on how to retrieve a data source object from a JNDI naming service.

 Context ctx = new InitialContext();
 DataSource ds = (DataSource)ctx.lookup("jdbc/MyDB");
        

See Also:
Serialized Form

Field Summary
private static long serialVersionUID
           
 
Fields inherited from class org.apache.derby.jdbc.EmbeddedBaseDataSource
attributesAsPassword, connectionAttributes, createDatabase, databaseName, dataSourceName, description, driver, jdbcurl, loginTimeout, shutdownDatabase
 
Constructor Summary
EmbeddedDataSource40()
           
 
Method Summary
 java.util.logging.Logger getParentLogger()
           
 
Methods inherited from class org.apache.derby.jdbc.EmbeddedDataSource
getReference
 
Methods inherited from class org.apache.derby.jdbc.ReferenceableDataSource
getObjectInstance
 
Methods inherited from class org.apache.derby.jdbc.EmbeddedBaseDataSource
equals, findDriver, getAttributesAsPassword, getConnection, getConnection, getConnection, getConnectionAttributes, getCreateDatabase, getDatabaseName, getDataSourceName, getDescription, getLoginTimeout, getLogWriter, getPassword, getShortDatabaseName, getShutdownDatabase, getUser, isWrapperFor, setAttributesAsPassword, setConnectionAttributes, setCreateDatabase, setDatabaseName, setDataSourceName, setDescription, setLoginTimeout, setLogWriter, setPassword, setShutdownDatabase, setupResourceAdapter, setUser, unwrap, update
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.sql.DataSource
getConnection, getConnection
 
Methods inherited from interface javax.sql.CommonDataSource
getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

EmbeddedDataSource40

public EmbeddedDataSource40()
Method Detail

getParentLogger

public java.util.logging.Logger getParentLogger()
                                         throws java.sql.SQLFeatureNotSupportedException
Throws:
java.sql.SQLFeatureNotSupportedException

Built on Wed 2013-06-12 15:21:56+0000, from revision ???

Apache Derby V10.10 Internals - Copyright © 2004,2013 The Apache Software Foundation. All Rights Reserved.