Package org.apache.derby.jdbc
Class BasicClientDataSource40
java.lang.Object
org.apache.derby.jdbc.BasicClientDataSource40
- All Implemented Interfaces:
Serializable
,Wrapper
,CommonDataSource
,DataSource
,ClientDataSourceInterface
- Direct Known Subclasses:
BasicClientConnectionPoolDataSource40
,BasicClientXADataSource40
,ClientDataSource
public class BasicClientDataSource40
extends Object
implements DataSource, ClientDataSourceInterface, Serializable
This data source is suitable for client/server use of Derby,
running on Java 8 Compact Profile 2 or higher.
BasicClientDataSource40 is similar to ClientDataSource except it
can not be used with JNDI, i.e. it does not implement
javax.naming.Referenceable
.
* The standard attributes provided are, cf. e.g. table
9.1 in the JDBC 4.2 specification.
- databaseName
- dataSourceName
- description
- password
- user
- networkProtocol
- roleName
- loginTimeout @see javax.sql.CommonDataSource set/get
- logWriter @see javax.sql.CommonDataSource set/get
- createDatabase
- connectionAttributes
- shutdownDatabase
- attributesAsPassword
- retrieveMessageText
- securityMechanism
- traceDirectory
- traceFile
- traceFileAppend
- traceLevel
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final short
See documentation atUSER_ONLY_SECURITY
private String
private boolean
Set to true if the database should be created.private String
Stores the relational database name, RDBNAME.private String
A data source name; used to name an underlying XADataSource, or ConnectionPoolDataSource when pooling of connections is done.private String
A description of this data source.static final short
See documentation atUSER_ONLY_SECURITY
static final short
See documentation atUSER_ONLY_SECURITY
private int
The time in seconds to wait for a connection request on this data source.private PrintWriter
The log writer is declared transient, and is not serialized or stored under JNDI.private String
private int
static final int
See documentation atTRACE_NONE
.private boolean
private static final short
private short
Security Mechanism can be specified explicitly either when obtaining a connection via a DriverManager or via Datasource.private static final long
private String
private boolean
Set to true if the database should be shutdown.static final int
The constant indicating that SSL encryption will be used.private static final String
static final int
The constant indicating that SSL encryption won't be used.private static final String
static final int
The constant indicating that SSL encryption with peer authentication will be used.private static final String
private int
static final short
See documentation atUSER_ONLY_SECURITY
static final int
See documentation atTRACE_NONE
.static final int
See documentation atTRACE_NONE
.static final int
See documentation atTRACE_NONE
.static final int
See documentation atTRACE_NONE
.static final int
See documentation atTRACE_NONE
.static final int
The client server protocol can be traced.static final int
See documentation atTRACE_NONE
.static final int
See documentation atTRACE_NONE
.static final int
See documentation atTRACE_NONE
.static final int
See documentation atTRACE_NONE
.static final int
See documentation atTRACE_NONE
.static final int
See documentation atTRACE_NONE
.private String
private String
private boolean
private int
private int
private String
This property can be overwritten by specifing the username parameter on the DataSource.getConnection() method call.static final short
The source security mechanism to use when connecting to a client data source.Fields inherited from interface org.apache.derby.jdbc.ClientDataSourceInterface
propertyDefault_portNumber, propertyDefault_retrieveMessageText, propertyDefault_securityMechanism, propertyDefault_serverName, propertyDefault_traceFileAppend, propertyDefault_user
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a simple DERBY data source with default property values for a non-pooling, non-distributed environment. -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
checkBoolean
(Properties set, String attribute) private static void
checkEnumeration
(Properties set, String attribute, String[] choices) private static LogWriter
computeDncLogWriter
(PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, String logWriterInUseSuffix, int traceFileSuffixIndex, int traceLevel) (package private) static LogWriter
computeDncLogWriterForNewConnection
(PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, int traceLevel, String logWriterInUseSuffix, int traceFileSuffixIndex) private LogWriter
computeDncLogWriterForNewConnection
(String logWriterInUseSuffix) private static PrintWriter
computePrintWriter
(PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, String logWriterInUseSuffix, int traceFileSuffixIndex) private String
Constructs the JDBC connection URL from the state of the data source.static int
getClientSSLMode
(Properties properties) Returns the SSL mode specified by the property object.Attempt to establish a database connection in a non-pooling, non-distributed environment.getConnection
(String user, String password) Attempt to establish a database connection in a non-pooling, non-distributed environment.private Connection
getConnectionX
(LogWriter dncLogWriter, String user, String password) int
static String
getPassword
(Properties properties) protected final PooledConnection
protected final PooledConnection
getPooledConnectionMinion
(String user, String password) private static PooledConnection
getPooledConnectionX
(LogWriter dncLogWriter, BasicClientDataSource40 ds, String user, String password) int
private static PrintWriter
getPrintWriter
(String fileName, boolean fileAppend) static Properties
boolean
static boolean
getRetrieveMessageText
(Properties properties) short
Return the security mechanism.short
getSecurityMechanism
(String password) Return the security mechanism for this datasource object.static short
getSecurityMechanism
(Properties properties) Return security mechanism if it is set, else upgrade the security mechanism if possible and return the upgraded security mechanismgetSsl()
Returns the SSL encryption mode specified for the data source.static int
Parses the string and returns the corresponding constant for the SSL mode denoted.(package private) static String
getTraceDirectory
(Properties properties) Check if derby.client.traceDirectory is provided as a JVM property.(package private) static String
getTraceFile
(Properties properties) boolean
(package private) static boolean
getTraceFileAppend
(Properties properties) int
(package private) static int
getTraceLevel
(Properties properties) Check if derby.client.traceLevel is provided as a JVM property.private static short
getUpgradedSecurityMechanism
(String password) This method has logic to upgrade security mechanism to a better (more secure) one if it is possible.getUser()
static String
getUser
(Properties properties) protected final XAConnection
protected final XAConnection
getXAConnectionMinion
(String user, String password) private static XAConnection
getXAConnectionX
(LogWriter dncLogWriter, BasicClientDataSource40 ds, String user, String password) Method that establishes the initial physical connection using DS properties instead of CPDS properties.private 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
(Class<?> iface) Check whether this instance wraps an object that implements the interface specified byiface
.int
Returns the maximum number of JDBC prepared statements a connection is allowed to cache.private static boolean
parseBoolean
(String boolString, boolean defaultBool) private static int
private static String
parseString
(String string, String defaultString) private static String
readSystemProperty
(String key) Read the value of the passed system property.void
Set this property to pass in more Derby specific connection URL attributes.void
setCreateDatabase
(String create) Set this property to create a new database.void
setDatabaseName
(String databaseName) void
setDataSourceName
(String dataSourceName) void
setDescription
(String description) void
setLoginTimeout
(int seconds) void
setLogWriter
(PrintWriter logWriter) void
setPassword
(String password) void
setPortNumber
(int portNumber) void
setRetrieveMessageText
(boolean retrieveMessageText) void
setSecurityMechanism
(short securityMechanism) Sets the security mechanism.void
setServerName
(String serverName) void
setShutdownDatabase
(String shutdown) Set this property if one wishes to shutdown the database identified by databaseName.void
Specifies the SSL encryption mode to use.void
setTraceDirectory
(String traceDirectory) void
setTraceFile
(String traceFile) void
setTraceFileAppend
(boolean traceFileAppend) void
setTraceLevel
(int traceLevel) void
(package private) static Properties
tokenizeAttributes
(String attributeString, Properties properties) <T> T
Returnsthis
if this class implements the specified interface.private void
The dataSource keeps individual fields for the values that are relevant to the client.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
className__
- See Also:
-
TRACE_NONE
public static final int TRACE_NONEThe client server protocol can be traced. The constants below define the tracing level, cf. the documentation section "Network Client Tracing" in the "Derby Server and Administration Guide". Cf. the connection attribute (or data source bean property)traceLevel
.TRACE_NONE TRACE_CONNECTION_CALLS TRACE_STATEMENT_CALLS TRACE_RESULT_SET_CALLS TRACE _DRIVER_CONFIGURATION TRACE_CONNECTS TRACE_PROTOCOL_FLOWS TRACE _RESULT_SET_META_DATA TRACE _PARAMETER_META_DATA TRACE_DIAGNOSTICS TRACE_XA_CALLS TRACE_ALL
- See Also:
-
TRACE_CONNECTION_CALLS
public static final int TRACE_CONNECTION_CALLSSee documentation atTRACE_NONE
.- See Also:
-
TRACE_STATEMENT_CALLS
public static final int TRACE_STATEMENT_CALLSSee documentation atTRACE_NONE
.- See Also:
-
TRACE_RESULT_SET_CALLS
public static final int TRACE_RESULT_SET_CALLSSee documentation atTRACE_NONE
.- See Also:
-
TRACE_DRIVER_CONFIGURATION
public static final int TRACE_DRIVER_CONFIGURATIONSee documentation atTRACE_NONE
.- See Also:
-
TRACE_CONNECTS
public static final int TRACE_CONNECTSSee documentation atTRACE_NONE
.- See Also:
-
TRACE_PROTOCOL_FLOWS
public static final int TRACE_PROTOCOL_FLOWSSee documentation atTRACE_NONE
.- See Also:
-
TRACE_RESULT_SET_META_DATA
public static final int TRACE_RESULT_SET_META_DATASee documentation atTRACE_NONE
.- See Also:
-
TRACE_PARAMETER_META_DATA
public static final int TRACE_PARAMETER_META_DATASee documentation atTRACE_NONE
.- See Also:
-
TRACE_DIAGNOSTICS
public static final int TRACE_DIAGNOSTICSSee documentation atTRACE_NONE
.- See Also:
-
TRACE_XA_CALLS
public static final int TRACE_XA_CALLSSee documentation atTRACE_NONE
.- See Also:
-
TRACE_ALL
public static final int TRACE_ALLSee documentation atTRACE_NONE
.- See Also:
-
propertyDefault_traceLevel
public static final int propertyDefault_traceLevelSee documentation atTRACE_NONE
.- See Also:
-
USER_ONLY_SECURITY
public static final short USER_ONLY_SECURITYThe source security mechanism to use when connecting to a client data source. Security mechanism options are:- USER_ONLY_SECURITY
- CLEAR_TEXT_PASSWORD_SECURITY
- ENCRYPTED_PASSWORD_SECURITY
- ENCRYPTED_USER_AND_PASSWORD_SECURITY - both password and user are encrypted
- STRONG_PASSWORD_SUBSTITUTE_SECURITY
- See Also:
-
CLEAR_TEXT_PASSWORD_SECURITY
public static final short CLEAR_TEXT_PASSWORD_SECURITYSee documentation atUSER_ONLY_SECURITY
- See Also:
-
ENCRYPTED_PASSWORD_SECURITY
public static final short ENCRYPTED_PASSWORD_SECURITYSee documentation atUSER_ONLY_SECURITY
- See Also:
-
ENCRYPTED_USER_AND_PASSWORD_SECURITY
public static final short ENCRYPTED_USER_AND_PASSWORD_SECURITYSee documentation atUSER_ONLY_SECURITY
- See Also:
-
STRONG_PASSWORD_SUBSTITUTE_SECURITY
public static final short STRONG_PASSWORD_SUBSTITUTE_SECURITYSee documentation atUSER_ONLY_SECURITY
- See Also:
-
loginTimeout
private int loginTimeoutThe time in seconds to wait for a connection request on this data source. The default value of zero indicates that either the system time out be used or no timeout limit. -
logWriter
The log writer is declared transient, and is not serialized or stored under JNDI.- See Also:
-
databaseName
Stores the relational database name, RDBNAME. The length of the database name may be limited to 18 bytes and therefore may throw an SQLException. -
description
A description of this data source. -
dataSourceName
A data source name; used to name an underlying XADataSource, or ConnectionPoolDataSource when pooling of connections is done. -
portNumber
private int portNumber -
serverName
-
SSL_OFF
public static final int SSL_OFFThe constant indicating that SSL encryption won't be used.- See Also:
-
SSL_OFF_STR
- See Also:
-
SSL_BASIC
public static final int SSL_BASICThe constant indicating that SSL encryption will be used.- See Also:
-
SSL_BASIC_STR
- See Also:
-
SSL_PEER_AUTHENTICATION
public static final int SSL_PEER_AUTHENTICATIONThe constant indicating that SSL encryption with peer authentication will be used.- See Also:
-
SSL_PEER_AUTHENTICATION_STR
- See Also:
-
user
This property can be overwritten by specifing the username parameter on the DataSource.getConnection() method call. If user is specified, then password must also be specified, either in the data source object or provided on the DataSource.getConnection() call. Each data source implementation subclass will maintain it's ownpassword
property. This password property may or may not be declared transient, and therefore may be serialized to a file in clear-text, care must taken by the user to prevent security breaches. Derby-406 fix -
SECMEC_HAS_NOT_EXPLICITLY_SET
private static final short SECMEC_HAS_NOT_EXPLICITLY_SET- See Also:
-
securityMechanism
private short securityMechanismSecurity Mechanism can be specified explicitly either when obtaining a connection via a DriverManager or via Datasource. Via DriverManager, securityMechanism can be set on the connection request using the 'securityMechanism' attribute. Via DataSource, securityMechanism can be set by calling setSecurityMechanism() on the ClientDataSource If the security mechanism is not explicitly set as mentioned above, in that case the Client will try to upgrade the security mechanism to a more secure one, if possible. SeegetUpgradedSecurityMechanism(java.lang.String)
. Therefore, need to keep track if the securityMechanism has been explicitly set. -
retrieveMessageText
private boolean retrieveMessageText -
traceFile
-
traceFileSuffixIndex_
private transient int traceFileSuffixIndex_ -
traceDirectory
-
traceFileAppend
private boolean traceFileAppend -
password
-
sslMode
private int sslMode -
createDatabase
private boolean createDatabaseSet to true if the database should be created. -
shutdownDatabase
private boolean shutdownDatabaseSet to true if the database should be shutdown. -
connectionAttributes
-
traceLevel
private int traceLevel
-
-
Constructor Details
-
BasicClientDataSource40
public BasicClientDataSource40()Creates a simple DERBY data source with default property values for a non-pooling, non-distributed environment. No particular DatabaseName or other properties are associated with the data source. Every Java Bean should provide a constructor with no arguments since many beanboxes attempt to instantiate a bean by invoking its no-argument constructor.
-
-
Method Details
-
setLoginTimeout
public void setLoginTimeout(int seconds) - Specified by:
setLoginTimeout
in interfaceCommonDataSource
- Specified by:
setLoginTimeout
in interfaceDataSource
-
getLoginTimeout
public int getLoginTimeout()- Specified by:
getLoginTimeout
in interfaceCommonDataSource
- Specified by:
getLoginTimeout
in interfaceDataSource
-
setLogWriter
- Specified by:
setLogWriter
in interfaceCommonDataSource
- Specified by:
setLogWriter
in interfaceDataSource
-
getLogWriter
- Specified by:
getLogWriter
in interfaceCommonDataSource
- Specified by:
getLogWriter
in interfaceDataSource
-
getSSLModeFromString
Parses the string and returns the corresponding constant for the SSL mode denoted.Valid values are off, basic and peerAuthentication.
- Parameters:
s
- string denoting the SSL mode- Returns:
- A constant indicating the SSL mode denoted by the string. If the
string is
null
,SSL_OFF
is returned. - Throws:
SqlException
- if the string has an invalid value
-
getClientSSLMode
Returns the SSL mode specified by the property object.- Parameters:
properties
- data source properties- Returns:
- A constant indicating the SSL mode to use. Defaults to
SSL_OFF
if the SSL attribute isn't specified. - Throws:
SqlException
- if an invalid value for the SSL mode is specified in the property object
-
getUser
-
getSecurityMechanism
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
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
-
getTraceFile
-
getTraceDirectory
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
-
readSystemProperty
Read the value of the passed system property. If we are running under the Java security manager and permission to read the property is missing,a null is returned, and no diagnostic is given (DERBY-6620).- Parameters:
key
- name of the system property- Returns:
- value of the system property, null if there is no permission to read the property
-
getTraceFileAppend
-
getPassword
-
setPassword
- Specified by:
setPassword
in interfaceClientDataSourceInterface
-
getPassword
- Specified by:
getPassword
in interfaceClientDataSourceInterface
-
computeDncLogWriterForNewConnection
private LogWriter computeDncLogWriterForNewConnection(String logWriterInUseSuffix) throws SqlException - Throws:
SqlException
-
computeDncLogWriterForNewConnection
static LogWriter computeDncLogWriterForNewConnection(PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, int traceLevel, String logWriterInUseSuffix, int traceFileSuffixIndex) throws SqlException - Throws:
SqlException
-
computeDncLogWriter
private static LogWriter computeDncLogWriter(PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, String logWriterInUseSuffix, int traceFileSuffixIndex, int traceLevel) throws SqlException - Throws:
SqlException
-
computePrintWriter
private static PrintWriter computePrintWriter(PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, String logWriterInUseSuffix, int traceFileSuffixIndex) throws SqlException - Throws:
SqlException
-
getPrintWriter
- Throws:
SqlException
-
parseBoolean
-
parseString
-
parseInt
-
tokenizeAttributes
static Properties tokenizeAttributes(String attributeString, Properties properties) throws SqlException - Throws:
SqlException
-
checkBoolean
- Throws:
SqlException
-
checkEnumeration
private static void checkEnumeration(Properties set, String attribute, String[] choices) throws SqlException - Throws:
SqlException
-
setDatabaseName
- Specified by:
setDatabaseName
in interfaceClientDataSourceInterface
-
getDatabaseName
- Specified by:
getDatabaseName
in interfaceClientDataSourceInterface
-
setDataSourceName
- Specified by:
setDataSourceName
in interfaceClientDataSourceInterface
-
getDataSourceName
- Specified by:
getDataSourceName
in interfaceClientDataSourceInterface
-
setDescription
- Specified by:
setDescription
in interfaceClientDataSourceInterface
-
getDescription
- Specified by:
getDescription
in interfaceClientDataSourceInterface
-
setPortNumber
public void setPortNumber(int portNumber) - Specified by:
setPortNumber
in interfaceClientDataSourceInterface
-
getPortNumber
public int getPortNumber()- Specified by:
getPortNumber
in interfaceClientDataSourceInterface
-
setServerName
- Specified by:
setServerName
in interfaceClientDataSourceInterface
-
getServerName
- Specified by:
getServerName
in interfaceClientDataSourceInterface
-
setUser
- Specified by:
setUser
in interfaceClientDataSourceInterface
-
getUser
- Specified by:
getUser
in interfaceClientDataSourceInterface
-
setRetrieveMessageText
public void setRetrieveMessageText(boolean retrieveMessageText) - Specified by:
setRetrieveMessageText
in interfaceClientDataSourceInterface
-
getRetrieveMessageText
public boolean getRetrieveMessageText()- Specified by:
getRetrieveMessageText
in interfaceClientDataSourceInterface
-
setSecurityMechanism
public void setSecurityMechanism(short securityMechanism) Sets the security mechanism.- Specified by:
setSecurityMechanism
in interfaceClientDataSourceInterface
- 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.- Specified by:
getSecurityMechanism
in interfaceClientDataSourceInterface
- Returns:
- the security mechanism
- See Also:
-
getSecurityMechanism
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.- Specified by:
getSecurityMechanism
in interfaceClientDataSourceInterface
- Parameters:
password
- password of user- Returns:
- the security mechanism
- See Also:
-
setSsl
Specifies the SSL encryption mode to use.Valid values are off, basic and peerAuthentication.
- Specified by:
setSsl
in interfaceClientDataSourceInterface
- Parameters:
mode
- the SSL mode to use (off, basic or peerAuthentication)- Throws:
SqlException
- if the specified mode is invalid
-
getSsl
Returns the SSL encryption mode specified for the data source.- Specified by:
getSsl
in interfaceClientDataSourceInterface
- Returns:
- off, basic or peerAuthentication.
-
setCreateDatabase
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.- Specified by:
setCreateDatabase
in interfaceClientDataSourceInterface
- 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
- Specified by:
getCreateDatabase
in interfaceClientDataSourceInterface
- Returns:
- "create" if create is set, or null if not
-
setShutdownDatabase
Set this property if one wishes to shutdown the database identified by databaseName.- Specified by:
setShutdownDatabase
in interfaceClientDataSourceInterface
- Parameters:
shutdown
- if set to the string "shutdown", this data source will shutdown the database if it is running.
-
getShutdownDatabase
- Specified by:
getShutdownDatabase
in interfaceClientDataSourceInterface
- Returns:
- "shutdown" if shutdown is set, or null if not
-
setConnectionAttributes
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.- Specified by:
setConnectionAttributes
in interfaceClientDataSourceInterface
- 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
- Specified by:
getConnectionAttributes
in interfaceClientDataSourceInterface
- Returns:
- Derby specific connection URL attributes
-
getTraceLevel
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) - Specified by:
setTraceLevel
in interfaceClientDataSourceInterface
-
getTraceLevel
public int getTraceLevel()- Specified by:
getTraceLevel
in interfaceClientDataSourceInterface
-
setTraceFile
- Specified by:
setTraceFile
in interfaceClientDataSourceInterface
-
getTraceFile
- Specified by:
getTraceFile
in interfaceClientDataSourceInterface
-
setTraceDirectory
- Specified by:
setTraceDirectory
in interfaceClientDataSourceInterface
-
getTraceDirectory
- Specified by:
getTraceDirectory
in interfaceClientDataSourceInterface
-
setTraceFileAppend
public void setTraceFileAppend(boolean traceFileAppend) - Specified by:
setTraceFileAppend
in interfaceClientDataSourceInterface
-
getTraceFileAppend
public boolean getTraceFileAppend()- Specified by:
getTraceFileAppend
in interfaceClientDataSourceInterface
-
maxStatementsToPool
public int maxStatementsToPool()Returns the maximum number of JDBC prepared statements a connection is allowed to cache.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
.- Returns:
- Maximum number of statements to cache, or
0
if caching is disabled (default).
-
updateDataSourceValues
The dataSource keeps individual fields for the values that are relevant to the client. These need to be updated when set connection attributes is called.- Throws:
SqlException
-
handleConnectionException
Handles common error situations that can happen when trying to obtain a physical connection to the server, and which require special handling.If this method returns normally, the exception wasn't handled and should be handled elsewhere or be re-thrown.
- Parameters:
logWriter
- log writer, may benull
sqle
- exception to handle- Throws:
SQLException
- handled exception (if any)
-
constructUrl
Constructs the JDBC connection URL from the state of the data source.- Returns:
- The JDBC connection URL.
-
getConnection
Attempt to establish a database connection in a non-pooling, non-distributed environment.- Specified by:
getConnection
in interfaceDataSource
- Returns:
- a Connection to the database
- Throws:
SQLException
- if a database-access error occurs.
-
getConnection
Attempt to establish a database connection in a non-pooling, non-distributed environment.- Specified by:
getConnection
in interfaceDataSource
- Parameters:
user
- the database user on whose behalf the Connection is being madepassword
- the user's password- Returns:
- a Connection to the database
- Throws:
SQLException
- if a database-access error occurs.
-
getConnectionX
private Connection getConnectionX(LogWriter dncLogWriter, String user, String password) throws SqlException - Throws:
SqlException
-
isWrapperFor
Check whether this instance wraps an object that implements the interface specified byiface
.- Specified by:
isWrapperFor
in interfaceWrapper
- Parameters:
iface
- a class defining an interface- Returns:
true
if this instance implementsiface
, orfalse
otherwise- Throws:
SQLException
- if an error occurs while determining if this instance implementsiface
-
unwrap
Returnsthis
if this class implements the specified interface.- Specified by:
unwrap
in interfaceWrapper
- Parameters:
iface
- a class defining an interface- Returns:
- an object that implements the interface
- Throws:
SQLException
- if no object is found that implements the interface
-
getParentLogger
- Specified by:
getParentLogger
in interfaceCommonDataSource
- Throws:
SQLFeatureNotSupportedException
-
getPooledConnectionMinion
- Throws:
SQLException
-
getPooledConnectionMinion
protected final PooledConnection getPooledConnectionMinion(String user, String password) throws SQLException - Throws:
SQLException
-
getPooledConnectionX
private static PooledConnection getPooledConnectionX(LogWriter dncLogWriter, BasicClientDataSource40 ds, String user, String password) throws SQLException - Throws:
SQLException
-
getXAConnectionMinion
- Throws:
SQLException
-
getXAConnectionMinion
protected final XAConnection getXAConnectionMinion(String user, String password) throws SQLException - Throws:
SQLException
-
getXAConnectionX
private static XAConnection getXAConnectionX(LogWriter dncLogWriter, BasicClientDataSource40 ds, String user, String password) throws SQLException Method that establishes the initial physical connection using DS properties instead of CPDS properties.- Throws:
SQLException
-
getProperties
-