org.apache.derby.jdbc
Class ReferenceableDataSource

java.lang.Object
  extended by org.apache.derby.jdbc.ReferenceableDataSource
All Implemented Interfaces:
java.io.Serializable, javax.naming.Referenceable, javax.naming.spi.ObjectFactory
Direct Known Subclasses:
EmbeddedDataSource

public class ReferenceableDataSource
extends java.lang.Object
implements javax.naming.Referenceable, java.io.Serializable, javax.naming.spi.ObjectFactory

Derby DataSource implementation base class. ReferenceableDataSource provides support for JDBC standard DataSource attributes and acts as the ObjectFactory to generate Derby DataSource implementations.

The standard attributes provided by this class are:


See the specific Derby DataSource implementation for details on their meaning.
See the JDBC 3.0 specification for more details.

See Also:
Serialized Form

Field Summary
private static java.lang.Class[] BOOLEAN_ARG
           
private  java.lang.String databaseName
           
private  java.lang.String dataSourceName
           
private  java.lang.String description
           
private static java.lang.Class[] INT_ARG
           
private  int loginTimeout
           
private  java.lang.String password
           
private  java.io.PrintWriter printer
          instance variables that will not be serialized
private static long serialVersionUID
           
private static java.lang.Class[] STRING_ARG
           
private  java.lang.String user
           
 
Constructor Summary
ReferenceableDataSource()
          No-arg constructor.
 
Method Summary
(package private)  java.sql.Connection getConnection(java.lang.String username, java.lang.String password, boolean requestPassword)
          Return a connection for the Derby family of data source implementations.
 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.Object getObjectInstance(java.lang.Object obj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable environment)
          Re-Create Derby datasource given a reference.
 java.lang.String getPassword()
           
 javax.naming.Reference getReference()
          Referenceable method.
 java.lang.String getUser()
           
 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 setUser(java.lang.String user)
          Set the user property for the data source.
(package private)  void update()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

STRING_ARG

private static final java.lang.Class[] STRING_ARG

INT_ARG

private static final java.lang.Class[] INT_ARG

BOOLEAN_ARG

private static final java.lang.Class[] BOOLEAN_ARG

description

private java.lang.String description

dataSourceName

private java.lang.String dataSourceName

databaseName

private java.lang.String databaseName

password

private java.lang.String password

user

private java.lang.String user

loginTimeout

private int loginTimeout

printer

private transient java.io.PrintWriter printer
instance variables that will not be serialized

Constructor Detail

ReferenceableDataSource

public ReferenceableDataSource()
No-arg constructor.

Method Detail

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

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.

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.

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.

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.

Parameters:
out - the new log writer; to disable, set to null
Throws:
java.sql.SQLException - if a database-access error occurs.

getObjectInstance

public java.lang.Object getObjectInstance(java.lang.Object obj,
                                          javax.naming.Name name,
                                          javax.naming.Context nameCtx,
                                          java.util.Hashtable environment)
                                   throws java.lang.Exception
Re-Create Derby datasource given a reference.

Specified by:
getObjectInstance in interface javax.naming.spi.ObjectFactory
Parameters:
obj - The possibly null object containing location or reference information that can be used in creating an object.
name - The name of this object relative to nameCtx, or null if no name is specified.
nameCtx - The context relative to which the name parameter is specified, or null if name is relative to the default initial context.
environment - The possibly null environment that is used in creating the object.
Returns:
One of the Derby datasource object created; null if an object cannot be created.
Throws:
java.lang.Exception - if this object factory encountered an exception while attempting to create an object, and no other object factories are to be tried.

getReference

public final javax.naming.Reference getReference()
                                          throws javax.naming.NamingException
Referenceable method.

Specified by:
getReference in interface javax.naming.Referenceable
Throws:
javax.naming.NamingException - cannot find named object

update

void update()

getConnection

java.sql.Connection getConnection(java.lang.String username,
                                  java.lang.String password,
                                  boolean requestPassword)
                            throws java.sql.SQLException
Return a connection for the Derby family of data source implementations.

Throws:
java.sql.SQLException

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

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