org.apache.derby.jdbc
Class ClientBaseDataSource

java.lang.Object
  extended by org.apache.derby.jdbc.ClientBaseDataSource
All Implemented Interfaces:
java.io.Serializable, javax.naming.Referenceable
Direct Known Subclasses:
org.apache.derby.jdbc.ClientDataSource

public abstract class ClientBaseDataSource
extends java.lang.Object
implements java.io.Serializable, javax.naming.Referenceable

Base class for client-side DataSource implementations.

See Also:
Serialized Form

Field Summary
static short CLEAR_TEXT_PASSWORD_SECURITY
           
protected  java.lang.String connectionAttributes
           
static short ENCRYPTED_PASSWORD_SECURITY
           
static short ENCRYPTED_USER_AND_PASSWORD_SECURITY
           
static int propertyDefault_portNumber
           
static boolean propertyDefault_retrieveMessageText
           
static short propertyDefault_securityMechanism
           
static java.lang.String propertyDefault_serverName
           
static boolean propertyDefault_traceFileAppend
           
static int propertyDefault_traceLevel
           
static java.lang.String propertyDefault_user
           
protected  short securityMechanism
           
static int SSL_BASIC
           
static int SSL_OFF
           
static int SSL_PEER_AUTHENTICATION
           
static short STRONG_PASSWORD_SUBSTITUTE_SECURITY
           
static int TRACE_ALL
           
static int TRACE_CONNECTION_CALLS
           
static int TRACE_CONNECTS
           
static int TRACE_DIAGNOSTICS
           
static int TRACE_DRIVER_CONFIGURATION
           
static int TRACE_NONE
           
static int TRACE_PARAMETER_META_DATA
           
static int TRACE_PROTOCOL_FLOWS
           
static int TRACE_RESULT_SET_CALLS
           
static int TRACE_RESULT_SET_META_DATA
           
static int TRACE_STATEMENT_CALLS
           
static int TRACE_XA_CALLS
           
protected  int traceLevel
           
static short USER_ONLY_SECURITY
          The source security mechanism to use when connecting to this data source.
 
Method Summary
static org.apache.derby.client.am.LogWriter computeDncLogWriter(org.apache.derby.client.am.Connection connection, java.io.PrintWriter logWriter, java.lang.String traceDirectory, java.lang.String traceFile, boolean traceFileAppend, java.lang.String logWriterInUseSuffix, int traceFileSuffixIndex, int traceLevel)
           
static int getClientSSLMode(java.util.Properties properties)
           
 java.lang.String getConnectionAttributes()
           
 java.lang.String getCreateDatabase()
           
 java.lang.String getDatabaseName()
           
 java.lang.String getDataSourceName()
           
 java.lang.String getDescription()
           
 int getLoginTimeout()
           
 java.io.PrintWriter getLogWriter()
           
 java.lang.String getPassword()
           
static java.lang.String getPassword(java.util.Properties properties)
           
 int getPortNumber()
           
 javax.naming.Reference getReference()
           
 boolean getRetrieveMessageText()
           
static boolean getRetrieveMessageText(java.util.Properties properties)
           
 short getSecurityMechanism()
          Return the security mechanism.
static short getSecurityMechanism(java.util.Properties properties)
          Return security mechanism if it is set, else upgrade the security mechanism if possible and return the upgraded security mechanism
 short getSecurityMechanism(java.lang.String password)
          Return the security mechanism for this datasource object.
 java.lang.String getServerName()
           
 java.lang.String getShutdownDatabase()
           
 java.lang.String getSsl()
           
static int getSSLModeFromString(java.lang.String s)
           
 java.lang.String getTraceDirectory()
           
static java.lang.String getTraceDirectory(java.util.Properties properties)
          Check if derby.client.traceDirectory is provided as a JVM property.
 java.lang.String getTraceFile()
           
static java.lang.String getTraceFile(java.util.Properties properties)
           
 boolean getTraceFileAppend()
           
static boolean getTraceFileAppend(java.util.Properties properties)
           
 int getTraceLevel()
           
static int getTraceLevel(java.util.Properties properties)
          Check if derby.client.traceLevel is provided as a JVM property.
static short getUpgradedSecurityMechanism(java.lang.String password)
          This method has logic to upgrade security mechanism to a better (more secure) one if it is possible.
 java.lang.String getUser()
           
static java.lang.String getUser(java.util.Properties properties)
           
 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)
           
 void setDataSourceName(java.lang.String dataSourceName)
           
 void setDescription(java.lang.String description)
           
 void setLoginTimeout(int seconds)
           
 void setLogWriter(java.io.PrintWriter logWriter)
           
 void setPassword(java.lang.String password)
           
 void setPortNumber(int portNumber)
           
 void setRetrieveMessageText(boolean retrieveMessageText)
           
 void setSecurityMechanism(short securityMechanism)
          Sets the security mechanism.
 void setServerName(java.lang.String serverName)
           
 void setShutdownDatabase(java.lang.String shutdown)
          Set this property if one wishes to shutdown the database identified by databaseName.
 void setSsl(int mode)
           
 void setSsl(java.lang.String mode)
           
 void setTraceDirectory(java.lang.String traceDirectory)
           
 void setTraceFile(java.lang.String traceFile)
           
 void setTraceFileAppend(boolean traceFileAppend)
           
 void setTraceLevel(int traceLevel)
           
 void setUser(java.lang.String user)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertyDefault_portNumber

public static final int propertyDefault_portNumber
See Also:
Constant Field Values

propertyDefault_serverName

public static final java.lang.String propertyDefault_serverName
See Also:
Constant Field Values

SSL_OFF

public static final int SSL_OFF
See Also:
Constant Field Values

SSL_BASIC

public static final int SSL_BASIC
See Also:
Constant Field Values

SSL_PEER_AUTHENTICATION

public static final int SSL_PEER_AUTHENTICATION
See Also:
Constant Field Values

propertyDefault_user

public static final java.lang.String propertyDefault_user
See Also:
Constant Field Values

securityMechanism

protected short securityMechanism

propertyDefault_securityMechanism

public static final short propertyDefault_securityMechanism
See Also:
Constant Field Values

propertyDefault_retrieveMessageText

public static final boolean propertyDefault_retrieveMessageText
See Also:
Constant Field Values

propertyDefault_traceFileAppend

public static final boolean propertyDefault_traceFileAppend
See Also:
Constant Field Values

USER_ONLY_SECURITY

public static final short USER_ONLY_SECURITY
The source security mechanism to use when connecting to this data source.

Security mechanism options are:

The default security mechanism is USER_ONLY SECURITY

If the application specifies a security mechanism then it will be the only one attempted. If the specified security mechanism is not supported by the conversation then an exception will be thrown and there will be no additional retries.

This property is currently only available for the DNC driver.

Both user and password need to be set for all security mechanism except USER_ONLY_SECURITY

See Also:
Constant Field Values

CLEAR_TEXT_PASSWORD_SECURITY

public static final short CLEAR_TEXT_PASSWORD_SECURITY
See Also:
Constant Field Values

ENCRYPTED_PASSWORD_SECURITY

public static final short ENCRYPTED_PASSWORD_SECURITY
See Also:
Constant Field Values

ENCRYPTED_USER_AND_PASSWORD_SECURITY

public static final short ENCRYPTED_USER_AND_PASSWORD_SECURITY
See Also:
Constant Field Values

STRONG_PASSWORD_SUBSTITUTE_SECURITY

public static final short STRONG_PASSWORD_SUBSTITUTE_SECURITY
See Also:
Constant Field Values

connectionAttributes

protected java.lang.String connectionAttributes

TRACE_NONE

public static final int TRACE_NONE
See Also:
Constant Field Values

TRACE_CONNECTION_CALLS

public static final int TRACE_CONNECTION_CALLS
See Also:
Constant Field Values

TRACE_STATEMENT_CALLS

public static final int TRACE_STATEMENT_CALLS
See Also:
Constant Field Values

TRACE_RESULT_SET_CALLS

public static final int TRACE_RESULT_SET_CALLS
See Also:
Constant Field Values

TRACE_DRIVER_CONFIGURATION

public static final int TRACE_DRIVER_CONFIGURATION
See Also:
Constant Field Values

TRACE_CONNECTS

public static final int TRACE_CONNECTS
See Also:
Constant Field Values

TRACE_PROTOCOL_FLOWS

public static final int TRACE_PROTOCOL_FLOWS
See Also:
Constant Field Values

TRACE_RESULT_SET_META_DATA

public static final int TRACE_RESULT_SET_META_DATA
See Also:
Constant Field Values

TRACE_PARAMETER_META_DATA

public static final int TRACE_PARAMETER_META_DATA
See Also:
Constant Field Values

TRACE_DIAGNOSTICS

public static final int TRACE_DIAGNOSTICS
See Also:
Constant Field Values

TRACE_XA_CALLS

public static final int TRACE_XA_CALLS
See Also:
Constant Field Values

TRACE_ALL

public static final int TRACE_ALL
See Also:
Constant Field Values

propertyDefault_traceLevel

public static final int propertyDefault_traceLevel
See Also:
Constant Field Values

traceLevel

protected int traceLevel
Method Detail

setLoginTimeout

public void setLoginTimeout(int seconds)

getLoginTimeout

public int getLoginTimeout()

setLogWriter

public void setLogWriter(java.io.PrintWriter logWriter)

getLogWriter

public java.io.PrintWriter getLogWriter()

getSSLModeFromString

public static final int getSSLModeFromString(java.lang.String s)
                                      throws org.apache.derby.client.am.SqlException
Throws:
org.apache.derby.client.am.SqlException

getClientSSLMode

public static final int getClientSSLMode(java.util.Properties properties)
                                  throws org.apache.derby.client.am.SqlException
Throws:
org.apache.derby.client.am.SqlException

getUser

public static java.lang.String getUser(java.util.Properties properties)

getSecurityMechanism

public static short getSecurityMechanism(java.util.Properties properties)
Return security mechanism if it is set, else upgrade the security mechanism if possible and return the upgraded security mechanism

Parameters:
properties - Look in the properties if securityMechanism is set or not if set, return this security mechanism
Returns:
security mechanism

getUpgradedSecurityMechanism

public static short getUpgradedSecurityMechanism(java.lang.String password)
This method has logic to upgrade security mechanism to a better (more secure) one if it is possible. Currently derby server only has support for USRIDPWD, USRIDONL, EUSRIDPWD and USRSSBPWD (10.2+) - this method only considers these possibilities. USRIDPWD, EUSRIDPWD and USRSSBPWD require a password, USRIDONL is the only security mechanism which does not require password. 1. if password is not available, then security mechanism possible is USRIDONL 2. if password is available,then USRIDPWD is returned.

Parameters:
password - password argument
Returns:
upgraded security mechanism if possible

getRetrieveMessageText

public static boolean getRetrieveMessageText(java.util.Properties properties)

getTraceFile

public static java.lang.String getTraceFile(java.util.Properties properties)

getTraceDirectory

public static java.lang.String getTraceDirectory(java.util.Properties properties)
Check if derby.client.traceDirectory is provided as a JVM property. If yes, then we use that value. If not, then we look for traceDirectory in the the properties parameter.

Parameters:
properties - jdbc url properties
Returns:
value of traceDirectory property

getTraceFileAppend

public static boolean getTraceFileAppend(java.util.Properties properties)

getPassword

public static java.lang.String getPassword(java.util.Properties properties)

setPassword

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

getPassword

public final java.lang.String getPassword()

getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.NamingException
Specified by:
getReference in interface javax.naming.Referenceable
Throws:
javax.naming.NamingException

computeDncLogWriter

public static org.apache.derby.client.am.LogWriter computeDncLogWriter(org.apache.derby.client.am.Connection connection,
                                                                       java.io.PrintWriter logWriter,
                                                                       java.lang.String traceDirectory,
                                                                       java.lang.String traceFile,
                                                                       boolean traceFileAppend,
                                                                       java.lang.String logWriterInUseSuffix,
                                                                       int traceFileSuffixIndex,
                                                                       int traceLevel)
                                                                throws org.apache.derby.client.am.SqlException
Throws:
org.apache.derby.client.am.SqlException

setDatabaseName

public void setDatabaseName(java.lang.String databaseName)

getDatabaseName

public java.lang.String getDatabaseName()

setDataSourceName

public void setDataSourceName(java.lang.String dataSourceName)

getDataSourceName

public java.lang.String getDataSourceName()

setDescription

public void setDescription(java.lang.String description)

getDescription

public java.lang.String getDescription()

setPortNumber

public void setPortNumber(int portNumber)

getPortNumber

public int getPortNumber()

setServerName

public void setServerName(java.lang.String serverName)

getServerName

public java.lang.String getServerName()

setUser

public void setUser(java.lang.String user)

getUser

public java.lang.String getUser()

setRetrieveMessageText

public void setRetrieveMessageText(boolean retrieveMessageText)

getRetrieveMessageText

public boolean getRetrieveMessageText()

setSecurityMechanism

public void setSecurityMechanism(short securityMechanism)
Sets the security mechanism.

Parameters:
securityMechanism - to set

getSecurityMechanism

public short getSecurityMechanism()
Return the security mechanism. If security mechanism has not been set explicitly on datasource, then upgrade the security mechanism to a more secure one if possible.

Returns:
the security mechanism
See Also:
getUpgradedSecurityMechanism(String)

getSecurityMechanism

public short getSecurityMechanism(java.lang.String password)
Return the security mechanism for this datasource object. If security mechanism has not been set explicitly on datasource, then upgrade the security mechanism to a more secure one if possible.

Parameters:
password - password of user
Returns:
the security mechanism
See Also:
getUpgradedSecurityMechanism(String)

setSsl

public void setSsl(java.lang.String mode)
            throws org.apache.derby.client.am.SqlException
Throws:
org.apache.derby.client.am.SqlException

setSsl

public void setSsl(int mode)

getSsl

public java.lang.String getSsl()

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 documentation for complete list.

getConnectionAttributes

public final java.lang.String getConnectionAttributes()
Returns:
Derby specific connection URL attributes

getTraceLevel

public static int getTraceLevel(java.util.Properties properties)
Check if derby.client.traceLevel is provided as a JVM property. If yes, then we use that value. If not, then we look for traceLevel in the the properties parameter.

Parameters:
properties - jdbc url properties
Returns:
value of traceLevel property

setTraceLevel

public void setTraceLevel(int traceLevel)

getTraceLevel

public int getTraceLevel()

setTraceFile

public void setTraceFile(java.lang.String traceFile)

getTraceFile

public java.lang.String getTraceFile()

setTraceDirectory

public void setTraceDirectory(java.lang.String traceDirectory)

getTraceDirectory

public java.lang.String getTraceDirectory()

setTraceFileAppend

public void setTraceFileAppend(boolean traceFileAppend)

getTraceFileAppend

public boolean getTraceFileAppend()

Built on Wed 2007-08-01 06:53:39-0700, from revision 561794

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