EmbeddedSimpleDataSource (Apache Derby 10.3 API Documentation)
Keywords: org.apache.derby.jdbc.EmbeddedSimpleDataSource class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.derby.jdbc
Class EmbeddedSimpleDataSource

    java.lang.Object
      org.apache.derby.jdbc.EmbeddedSimpleDataSource

All Implemented Interfaces:
  javax.sql.DataSource

public final class EmbeddedSimpleDataSource
extends java.lang.Object
implements javax.sql.DataSource

EmbeddedSimpleDataSource is Derby's DataSource implementation for J2ME/CDC/Foundation. It is also supports J2SE platforms. Supports the same properties as EmbeddedDataSource, see that class for details.

EmbeddedSimpleDataSource automatically supports the correct JDBC specification version for the Java Virtual Machine's environment.

- JDBC Optional Package for CDC/Foundation Profile(JSR-169) - J2ME - CDC/Foundation
- JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0

See Also:
  `EmbeddedDataSource`

Constructor Summary
`EmbeddedSimpleDataSource()` No-arg constructor.

Method Summary
`java.sql.Connection` | `getConnection()` Attempt to establish a database connection.
`java.sql.Connection` | `getConnection(java.lang.String username, java.lang.String password)` Attempt to establish a database connection with the given username and password.
`java.lang.String` | `getConnectionAttributes()`
`java.lang.String` | `getCreateDatabase()`
`java.lang.String` | `getDatabaseName()`
`java.lang.String` | `getDataSourceName()`
`java.lang.String` | `getDescription()`
`int` | `getLoginTimeout()` Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.
`java.io.PrintWriter` | `getLogWriter()` Get the log writer for this data source.
`java.lang.String` | `getPassword()`
`java.lang.String` | `getShutdownDatabase()`
`java.lang.String` | `getUser()`
`void` | `setConnectionAttributes(java.lang.String prop)` Set this property to pass in more Derby specific connection URL attributes.
`void` | `setCreateDatabase(java.lang.String create)` Set this property to create a new database.
`void` | `setDatabaseName(java.lang.String databaseName)` Set the database name.
`void` | `setDataSourceName(java.lang.String dsn)` Set the data source name.
`void` | `setDescription(java.lang.String desc)` Set the data source descripton.
`void` | `setLoginTimeout(int seconds)` Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.
`void` | `setLogWriter(java.io.PrintWriter out)` Set the log writer for this data source.
`void` | `setPassword(java.lang.String password)` Set the `password` property for the data source.
`void` | `setShutdownDatabase(java.lang.String shutdown)` Set this property if one wishes to shutdown the database identified by databaseName.
`void` | `setUser(java.lang.String user)` Set the `user` property for the data source.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### EmbeddedSimpleDataSource

    public EmbeddedSimpleDataSource()

  No-arg constructor.

Method Detail

### getLoginTimeout

    public int getLoginTimeout()
                        throws java.sql.SQLException

  Gets the maximum time in seconds that this data source can wait while attempting to connect to a database. A value of zero means that the timeout is the default system timeout if there is one; otherwise it means that there is no timeout. When a data source object is created, the login timeout is initially zero.

  Specified by:
    `getLoginTimeout` in interface `javax.sql.DataSource`
  Returns:
    the data source login time limit
  Throws:
    `java.sql.SQLException` - if a database access error occurs.

### setLoginTimeout

    public void setLoginTimeout(int seconds)
                         throws java.sql.SQLException

  Sets the maximum time in seconds that this data source will wait while attempting to connect to a database. A value of zero specifies that the timeout is the default system timeout if there is one; otherwise it specifies that there is no timeout. When a data source object is created, the login timeout is initially zero.

  Derby ignores this property.

  Specified by:
    `setLoginTimeout` in interface `javax.sql.DataSource`
  Parameters:
    `seconds` - the data source login time limit
  Throws:
    `java.sql.SQLException` - if a database access error occurs.

### getLogWriter

    public java.io.PrintWriter getLogWriter()
                                     throws java.sql.SQLException

  Get the log writer for this data source.

  The log writer is a character output stream to which all logging and tracing messages for this data source object instance will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the java.sql.Drivermanager class. When a data source object is created the log writer is initially null, in other words, logging is disabled.

  Specified by:
    `getLogWriter` in interface `javax.sql.DataSource`
  Returns:
    the log writer for this data source, null if disabled
  Throws:
    `java.sql.SQLException` - if a database-access error occurs.

### setLogWriter

    public void setLogWriter(java.io.PrintWriter out)
                      throws java.sql.SQLException

  Set the log writer for this data source.

  The log writer is a character output stream to which all logging and tracing messages for this data source object instance will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the java.sql.Drivermanager class. When a data source object is created the log writer is initially null, in other words, logging is disabled.

  Specified by:
    `setLogWriter` in interface `javax.sql.DataSource`
  Parameters:
    `out` - the new log writer; to disable, set to null
  Throws:
    `java.sql.SQLException` - if a database-access error occurs.

### setDatabaseName

    public final void setDatabaseName(java.lang.String databaseName)

  Set the database name. Setting this property is mandatory. If a database named wombat at g:/db needs to be accessed, database name should be set to "g:/db/wombat". The database will be booted if it is not already running in the system.

  Parameters:
    `databaseName` - the name of the database

### getDatabaseName

    public java.lang.String getDatabaseName()

### setDataSourceName

    public final void setDataSourceName(java.lang.String dsn)

  Set the data source name. The property is not mandatory. It is used for informational purposes only.

  Parameters:
    `dsn` - the name of the data source

### getDataSourceName

    public final java.lang.String getDataSourceName()

  Returns:
    data source name

### setDescription

    public final void setDescription(java.lang.String desc)

  Set the data source descripton. This property is not mandatory. It is used for informational purposes only.

  Parameters:
    `desc` - the description of the data source

### getDescription

    public final java.lang.String getDescription()

  Returns:
    description

### setUser

    public final void setUser(java.lang.String user)

  Set the `user` property for the data source. This is user name for any data source getConnection() call that takes no arguments.

### getUser

    public final java.lang.String getUser()

  Returns:
    user

### setPassword

    public final void setPassword(java.lang.String password)

  Set the `password` property for the data source. This is user's password for any data source getConnection() call that takes no arguments.

### getPassword

    public final java.lang.String getPassword()

  Returns:
    password

### setCreateDatabase

    public final void setCreateDatabase(java.lang.String create)

  Set this property to create a new database. If this property is not set, the database (identified by databaseName) is assumed to be already existing.

  Parameters:
    `create` - if set to the string "create", this data source will try to create a new database of databaseName, or boot the database if one by that name already exists.

### getCreateDatabase

    public final java.lang.String getCreateDatabase()

  Returns:
    "create" if create is set, or null if not

### setShutdownDatabase

    public final void setShutdownDatabase(java.lang.String shutdown)

  Set this property if one wishes to shutdown the database identified by databaseName.

  Parameters:
    `shutdown` - if set to the string "shutdown", this data source will shutdown the database if it is running.

### getShutdownDatabase

    public final java.lang.String getShutdownDatabase()

  Returns:
    "shutdown" if shutdown is set, or null if not

### setConnectionAttributes

    public final void setConnectionAttributes(java.lang.String prop)

  Set this property to pass in more Derby specific connection URL attributes.
  Any attributes that can be set using a property of this DataSource implementation (e.g user, password) should not be set in connectionAttributes. Conflicting settings in connectionAttributes and properties of the DataSource will lead to unexpected behaviour.

  Parameters:
    `prop` - set to the list of Derby connection attributes separated by semi-colons. E.g., to specify an encryption bootPassword of "x8hhk2adf", and set upgrade to true, do the following:

         ds.setConnectionAttributes("bootPassword=x8hhk2adf;upgrade=true");

    See Derby's documentation for complete list.

### getConnectionAttributes

    public final java.lang.String getConnectionAttributes()

  Returns:
    Derby specific connection URL attributes

### getConnection

    public final java.sql.Connection getConnection()
                                            throws java.sql.SQLException

  Attempt to establish a database connection.

  Specified by:
    `getConnection` in interface `javax.sql.DataSource`
  Returns:
    a Connection to the database
  Throws:
    `java.sql.SQLException` - if a database-access error occurs.

### getConnection

    public final java.sql.Connection getConnection(java.lang.String username,
                                                   java.lang.String password)
                                            throws java.sql.SQLException

  Attempt to establish a database connection with the given username and password. If the attributeAsPassword property is set to true then the password argument is taken to be a list of connection attributes with the same format as the connectionAttributes property.

  Specified by:
    `getConnection` in interface `javax.sql.DataSource`
  Parameters:
    `username` - the database user on whose behalf the Connection is being made
    `password` - the user's password
  Returns:
    a Connection to the database
  Throws:
    `java.sql.SQLException` - if a database-access error occurs.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Built on Wed 2007-08-01 06:53:39-0700, from revision 561794
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Apache Derby 10.3 API Documentation - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.