public abstract class ClientBaseDataSourceRoot extends java.lang.Object implements java.io.Serializable, ClientDataSourceInterface
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
connectionAttributes |
private boolean |
createDatabase
Set to true if the database should be created.
|
private java.lang.String |
databaseName |
private java.lang.String |
dataSourceName |
private java.lang.String |
description |
private int |
loginTimeout
The time in seconds to wait for a connection request on this data
source.
|
private java.io.PrintWriter |
logWriter
The log writer is declared transient, and is not serialized or stored
under JNDI.
|
private java.lang.String |
password |
private int |
portNumber |
private boolean |
retrieveMessageText |
private static short |
SECMEC_HAS_NOT_EXPLICITLY_SET |
protected short |
securityMechanism |
private static long |
serialVersionUID |
private java.lang.String |
serverName |
private boolean |
shutdownDatabase
Set to true if the database should be shutdown.
|
static int |
SSL_BASIC
The constant indicating that SSL encryption will be used.
|
private static java.lang.String |
SSL_BASIC_STR |
static int |
SSL_OFF
The constant indicating that SSL encryption won't be used.
|
private static java.lang.String |
SSL_OFF_STR |
static int |
SSL_PEER_AUTHENTICATION
The constant indicating that SSL encryption with peer authentication
will be used.
|
private static java.lang.String |
SSL_PEER_AUTHENTICATION_STR |
private int |
sslMode |
(package private) static boolean |
SUPPORTS_EUSRIDPWD |
private java.lang.String |
traceDirectory |
private java.lang.String |
traceFile |
private boolean |
traceFileAppend |
private int |
traceFileSuffixIndex_ |
protected int |
traceLevel |
private java.lang.String |
user |
CLEAR_TEXT_PASSWORD_SECURITY, ENCRYPTED_PASSWORD_SECURITY, ENCRYPTED_USER_AND_PASSWORD_SECURITY, propertyDefault_portNumber, propertyDefault_retrieveMessageText, propertyDefault_securityMechanism, propertyDefault_serverName, propertyDefault_traceFileAppend, propertyDefault_traceLevel, propertyDefault_user, STRONG_PASSWORD_SUBSTITUTE_SECURITY, TRACE_ALL, TRACE_CONNECTION_CALLS, TRACE_CONNECTS, TRACE_DIAGNOSTICS, TRACE_DRIVER_CONFIGURATION, TRACE_NONE, TRACE_PARAMETER_META_DATA, TRACE_PROTOCOL_FLOWS, TRACE_RESULT_SET_CALLS, TRACE_RESULT_SET_META_DATA, TRACE_STATEMENT_CALLS, TRACE_XA_CALLS, USER_ONLY_SECURITY| Constructor and Description |
|---|
ClientBaseDataSourceRoot() |
| Modifier and Type | Method and Description |
|---|---|
private static void |
checkBoolean(java.util.Properties set,
java.lang.String attribute) |
private static void |
checkEnumeration(java.util.Properties set,
java.lang.String attribute,
java.lang.String[] choices) |
static LogWriter |
computeDncLogWriter(Connection connection,
java.io.PrintWriter logWriter,
java.lang.String traceDirectory,
java.lang.String traceFile,
boolean traceFileAppend,
java.lang.String logWriterInUseSuffix,
int traceFileSuffixIndex,
int traceLevel) |
(package private) static LogWriter |
computeDncLogWriter(java.io.PrintWriter logWriter,
java.lang.String traceDirectory,
java.lang.String traceFile,
boolean traceFileAppend,
java.lang.String logWriterInUseSuffix,
int traceFileSuffixIndex,
int traceLevel) |
(package private) static LogWriter |
computeDncLogWriterForNewConnection(java.io.PrintWriter logWriter,
java.lang.String traceDirectory,
java.lang.String traceFile,
boolean traceFileAppend,
int traceLevel,
java.lang.String logWriterInUseSuffix,
int traceFileSuffixIndex) |
(package private) LogWriter |
computeDncLogWriterForNewConnection(java.lang.String logWriterInUseSuffix) |
(package private) static java.io.PrintWriter |
computePrintWriter(java.io.PrintWriter logWriter,
java.lang.String traceDirectory,
java.lang.String traceFile,
boolean traceFileAppend,
java.lang.String logWriterInUseSuffix,
int traceFileSuffixIndex) |
private java.lang.String |
constructUrl()
Constructs the JDBC connection URL from the state of the data source.
|
static int |
getClientSSLMode(java.util.Properties properties)
Returns the SSL mode specified by the property object.
|
java.sql.Connection |
getConnection()
Attempt to establish a database connection in a non-pooling,
non-distributed environment.
|
java.sql.Connection |
getConnection(java.lang.String user,
java.lang.String password)
Attempt to establish a database connection in a non-pooling,
non-distributed environment.
|
java.lang.String |
getConnectionAttributes() |
private java.sql.Connection |
getConnectionX(LogWriter dncLogWriter,
java.lang.String user,
java.lang.String password) |
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) |
protected javax.sql.PooledConnection |
getPooledConnectionMinion() |
protected javax.sql.PooledConnection |
getPooledConnectionMinion(java.lang.String user,
java.lang.String password) |
private static javax.sql.PooledConnection |
getPooledConnectionX(LogWriter dncLogWriter,
ClientBaseDataSourceRoot ds,
java.lang.String user,
java.lang.String password) |
int |
getPortNumber() |
static java.util.Properties |
getProperties(ClientBaseDataSourceRoot ths) |
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()
Returns the SSL encryption mode specified for the data source.
|
static int |
getSSLModeFromString(java.lang.String s)
Parses the string and returns the corresponding constant for the SSL
mode denoted.
|
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) |
protected javax.sql.XAConnection |
getXAConnectionMinion() |
protected javax.sql.XAConnection |
getXAConnectionMinion(java.lang.String user,
java.lang.String password) |
private static javax.sql.XAConnection |
getXAConnectionX(LogWriter dncLogWriter,
ClientBaseDataSourceRoot ds,
java.lang.String user,
java.lang.String password)
Method that establishes the initial physical connection
using DS properties instead of CPDS properties.
|
protected void |
handleConnectionException(LogWriter logWriter,
SqlException sqle)
Handles common error situations that can happen when trying to
obtain a physical connection to the server, and which require special
handling.
|
boolean |
isWrapperFor(java.lang.Class<?> iface)
Check whether this instance wraps an object that implements the
interface specified by
iface. |
int |
maxStatementsToPool()
Returns the maximum number of JDBC prepared statements a connection is
allowed to cache.
|
private static boolean |
parseBoolean(java.lang.String boolString,
boolean defaultBool) |
private static int |
parseInt(java.lang.String intString,
int defaultInt) |
private static java.lang.String |
parseString(java.lang.String string,
java.lang.String defaultString) |
private static java.lang.String |
readSystemProperty(java.lang.String key)
Read the value of the passed system property.
|
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(java.lang.String mode)
Specifices the SSL encryption mode to use.
|
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) |
(package private) static java.util.Properties |
tokenizeAttributes(java.lang.String attributeString,
java.util.Properties properties) |
<T> T |
unwrap(java.lang.Class<T> iface)
Returns
this if this class implements the specified interface. |
(package private) void |
updateDataSourceValues(java.util.Properties prop)
The dataSource keeps individual fields for the values that are relevant
to the client.
|
private static final long serialVersionUID
static final boolean SUPPORTS_EUSRIDPWD
private int loginTimeout
private transient java.io.PrintWriter logWriter
traceLevelprivate java.lang.String databaseName
private java.lang.String description
private java.lang.String dataSourceName
private int portNumber
private java.lang.String serverName
public static final int SSL_OFF
private static final java.lang.String SSL_OFF_STR
public static final int SSL_BASIC
private static final java.lang.String SSL_BASIC_STR
public static final int SSL_PEER_AUTHENTICATION
private static final java.lang.String SSL_PEER_AUTHENTICATION_STR
private java.lang.String user
private static final short SECMEC_HAS_NOT_EXPLICITLY_SET
protected short securityMechanism
private boolean retrieveMessageText
private java.lang.String traceFile
private transient int traceFileSuffixIndex_
private java.lang.String traceDirectory
private boolean traceFileAppend
private java.lang.String password
private int sslMode
private boolean createDatabase
private boolean shutdownDatabase
protected java.lang.String connectionAttributes
protected int traceLevel
public void setLoginTimeout(int seconds)
setLoginTimeout in interface javax.sql.CommonDataSourcepublic int getLoginTimeout()
getLoginTimeout in interface javax.sql.CommonDataSourcepublic void setLogWriter(java.io.PrintWriter logWriter)
setLogWriter in interface javax.sql.CommonDataSourcepublic java.io.PrintWriter getLogWriter()
getLogWriter in interface javax.sql.CommonDataSourcepublic static int getSSLModeFromString(java.lang.String s)
throws SqlException
Valid values are off, basic and peerAuthentication.
s - string denoting the SSL modenull, SSL_OFF is returned.SqlException - if the string has an invalid valuepublic static int getClientSSLMode(java.util.Properties properties)
throws SqlException
properties - data source propertiesSSL_OFF if the SSL attribute isn't specified.SqlException - if an invalid value for the SSL mode is specified
in the property objectpublic static java.lang.String getUser(java.util.Properties properties)
public static short getSecurityMechanism(java.util.Properties properties)
properties - Look in the properties if securityMechanism is set
or not
if set, return this security mechanismpublic static short getUpgradedSecurityMechanism(java.lang.String password)
password - password argumentpublic static boolean getRetrieveMessageText(java.util.Properties properties)
public static java.lang.String getTraceFile(java.util.Properties properties)
public static java.lang.String getTraceDirectory(java.util.Properties properties)
properties - jdbc url propertiesprivate static java.lang.String readSystemProperty(java.lang.String key)
key - name of the system propertypublic static boolean getTraceFileAppend(java.util.Properties properties)
public static java.lang.String getPassword(java.util.Properties properties)
public final void setPassword(java.lang.String password)
setPassword in interface ClientDataSourceInterfacepublic final java.lang.String getPassword()
getPassword in interface ClientDataSourceInterfaceLogWriter computeDncLogWriterForNewConnection(java.lang.String logWriterInUseSuffix) throws SqlException
SqlExceptionstatic LogWriter computeDncLogWriterForNewConnection(java.io.PrintWriter logWriter, java.lang.String traceDirectory, java.lang.String traceFile, boolean traceFileAppend, int traceLevel, java.lang.String logWriterInUseSuffix, int traceFileSuffixIndex) throws SqlException
SqlExceptionstatic LogWriter computeDncLogWriter(java.io.PrintWriter logWriter, java.lang.String traceDirectory, java.lang.String traceFile, boolean traceFileAppend, java.lang.String logWriterInUseSuffix, int traceFileSuffixIndex, int traceLevel) throws SqlException
SqlExceptionpublic static LogWriter computeDncLogWriter(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 SqlException
SqlExceptionstatic java.io.PrintWriter computePrintWriter(java.io.PrintWriter logWriter,
java.lang.String traceDirectory,
java.lang.String traceFile,
boolean traceFileAppend,
java.lang.String logWriterInUseSuffix,
int traceFileSuffixIndex)
throws SqlException
SqlExceptionprivate static boolean parseBoolean(java.lang.String boolString,
boolean defaultBool)
private static java.lang.String parseString(java.lang.String string,
java.lang.String defaultString)
private static int parseInt(java.lang.String intString,
int defaultInt)
static java.util.Properties tokenizeAttributes(java.lang.String attributeString,
java.util.Properties properties)
throws SqlException
SqlExceptionprivate static void checkBoolean(java.util.Properties set,
java.lang.String attribute)
throws SqlException
SqlExceptionprivate static void checkEnumeration(java.util.Properties set,
java.lang.String attribute,
java.lang.String[] choices)
throws SqlException
SqlExceptionpublic void setDatabaseName(java.lang.String databaseName)
setDatabaseName in interface ClientDataSourceInterfacepublic java.lang.String getDatabaseName()
getDatabaseName in interface ClientDataSourceInterfacepublic void setDataSourceName(java.lang.String dataSourceName)
setDataSourceName in interface ClientDataSourceInterfacepublic java.lang.String getDataSourceName()
getDataSourceName in interface ClientDataSourceInterfacepublic void setDescription(java.lang.String description)
setDescription in interface ClientDataSourceInterfacepublic java.lang.String getDescription()
getDescription in interface ClientDataSourceInterfacepublic void setPortNumber(int portNumber)
setPortNumber in interface ClientDataSourceInterfacepublic int getPortNumber()
getPortNumber in interface ClientDataSourceInterfacepublic void setServerName(java.lang.String serverName)
setServerName in interface ClientDataSourceInterfacepublic java.lang.String getServerName()
getServerName in interface ClientDataSourceInterfacepublic void setUser(java.lang.String user)
setUser in interface ClientDataSourceInterfacepublic java.lang.String getUser()
getUser in interface ClientDataSourceInterfacepublic void setRetrieveMessageText(boolean retrieveMessageText)
setRetrieveMessageText in interface ClientDataSourceInterfacepublic boolean getRetrieveMessageText()
getRetrieveMessageText in interface ClientDataSourceInterfacepublic void setSecurityMechanism(short securityMechanism)
setSecurityMechanism in interface ClientDataSourceInterfacesecurityMechanism - to setpublic short getSecurityMechanism()
getSecurityMechanism in interface ClientDataSourceInterfacegetUpgradedSecurityMechanism(String)public short getSecurityMechanism(java.lang.String password)
getSecurityMechanism in interface ClientDataSourceInterfacepassword - password of usergetUpgradedSecurityMechanism(String)public void setSsl(java.lang.String mode)
throws SqlException
Valid values are off, basic and peerAuthentication.
setSsl in interface ClientDataSourceInterfacemode - the SSL mode to use (off, basic or
peerAuthentication)SqlException - if the specified mode is invalidpublic java.lang.String getSsl()
getSsl in interface ClientDataSourceInterfacepublic final void setCreateDatabase(java.lang.String create)
setCreateDatabase in interface ClientDataSourceInterfacecreate - 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.public final java.lang.String getCreateDatabase()
getCreateDatabase in interface ClientDataSourceInterfacepublic final void setShutdownDatabase(java.lang.String shutdown)
setShutdownDatabase in interface ClientDataSourceInterfaceshutdown - if set to the string "shutdown", this data source will
shutdown the database if it is running.public final java.lang.String getShutdownDatabase()
getShutdownDatabase in interface ClientDataSourceInterfacepublic final void setConnectionAttributes(java.lang.String prop)
setConnectionAttributes in interface ClientDataSourceInterfaceprop - 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.public final java.lang.String getConnectionAttributes()
getConnectionAttributes in interface ClientDataSourceInterfacepublic static int getTraceLevel(java.util.Properties properties)
properties - jdbc url propertiespublic void setTraceLevel(int traceLevel)
setTraceLevel in interface ClientDataSourceInterfacepublic int getTraceLevel()
getTraceLevel in interface ClientDataSourceInterfacepublic void setTraceFile(java.lang.String traceFile)
setTraceFile in interface ClientDataSourceInterfacepublic java.lang.String getTraceFile()
getTraceFile in interface ClientDataSourceInterfacepublic void setTraceDirectory(java.lang.String traceDirectory)
setTraceDirectory in interface ClientDataSourceInterfacepublic java.lang.String getTraceDirectory()
getTraceDirectory in interface ClientDataSourceInterfacepublic void setTraceFileAppend(boolean traceFileAppend)
setTraceFileAppend in interface ClientDataSourceInterfacepublic boolean getTraceFileAppend()
getTraceFileAppend in interface ClientDataSourceInterfacepublic int maxStatementsToPool()
A basic data source will always return zero. If statement caching is
required, use a ConnectionPoolDataSource.
This method is used internally by Derby to determine if statement
pooling is to be enabled or not.
Not part of public API, so not present in
ClientDataSourceInterface.
0 if
caching is disabled (default).void updateDataSourceValues(java.util.Properties prop)
throws SqlException
SqlExceptionprotected final void handleConnectionException(LogWriter logWriter, SqlException sqle) throws java.sql.SQLException
If this method returns normally, the exception wasn't handled and should be handled elsewhere or be re-thrown.
logWriter - log writer, may be nullsqle - exception to handlejava.sql.SQLException - handled exception (if any)private java.lang.String constructUrl()
public java.sql.Connection getConnection()
throws java.sql.SQLException
getConnection in interface javax.sql.DataSourcejava.sql.SQLException - if a database-access error occurs.public java.sql.Connection getConnection(java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
getConnection in interface javax.sql.DataSourceuser - the database user on whose behalf the Connection is being
madepassword - the user's passwordjava.sql.SQLException - if a database-access error occurs.private java.sql.Connection getConnectionX(LogWriter dncLogWriter, java.lang.String user, java.lang.String password) throws SqlException
SqlExceptionpublic boolean isWrapperFor(java.lang.Class<?> iface)
throws java.sql.SQLException
iface.isWrapperFor in interface java.sql.Wrapperiface - a class defining an interfacetrue if this instance implements iface, or
false otherwisejava.sql.SQLException - if an error occurs while determining if this
instance implements ifacepublic <T> T unwrap(java.lang.Class<T> iface)
throws java.sql.SQLException
this if this class implements the specified interface.unwrap in interface java.sql.Wrapperiface - a class defining an interfacejava.sql.SQLException - if no object is found that implements the
interfaceprotected final javax.sql.PooledConnection getPooledConnectionMinion()
throws java.sql.SQLException
java.sql.SQLExceptionprotected final javax.sql.PooledConnection getPooledConnectionMinion(java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprivate static javax.sql.PooledConnection getPooledConnectionX(LogWriter dncLogWriter, ClientBaseDataSourceRoot ds, java.lang.String user, java.lang.String password) throws java.sql.SQLException
java.sql.SQLExceptionprotected final javax.sql.XAConnection getXAConnectionMinion()
throws java.sql.SQLException
java.sql.SQLExceptionprotected final javax.sql.XAConnection getXAConnectionMinion(java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLExceptionprivate static javax.sql.XAConnection getXAConnectionX(LogWriter dncLogWriter, ClientBaseDataSourceRoot ds, java.lang.String user, java.lang.String password) throws java.sql.SQLException
java.sql.SQLExceptionpublic static java.util.Properties getProperties(ClientBaseDataSourceRoot ths)
Apache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.