Package org.apache.derby.jdbc
Class BasicClientDataSource40
- java.lang.Object
-
- org.apache.derby.jdbc.BasicClientDataSource40
-
- All Implemented Interfaces:
java.io.Serializable,java.sql.Wrapper,javax.sql.CommonDataSource,javax.sql.DataSource,ClientDataSourceInterface
- Direct Known Subclasses:
BasicClientConnectionPoolDataSource40,BasicClientXADataSource40,ClientDataSource
public class BasicClientDataSource40 extends java.lang.Object implements javax.sql.DataSource, ClientDataSourceInterface, java.io.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 implementjavax.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringclassName__static shortCLEAR_TEXT_PASSWORD_SECURITYSee documentation atUSER_ONLY_SECURITYprivate java.lang.StringconnectionAttributesprivate booleancreateDatabaseSet to true if the database should be created.private java.lang.StringdatabaseNameStores the relational database name, RDBNAME.private java.lang.StringdataSourceNameA data source name; used to name an underlying XADataSource, or ConnectionPoolDataSource when pooling of connections is done.private java.lang.StringdescriptionA description of this data source.static shortENCRYPTED_PASSWORD_SECURITYSee documentation atUSER_ONLY_SECURITYstatic shortENCRYPTED_USER_AND_PASSWORD_SECURITYSee documentation atUSER_ONLY_SECURITYprivate intloginTimeoutThe time in seconds to wait for a connection request on this data source.private java.io.PrintWriterlogWriterThe log writer is declared transient, and is not serialized or stored under JNDI.private java.lang.Stringpasswordprivate intportNumberstatic intpropertyDefault_traceLevelSee documentation atTRACE_NONE.private booleanretrieveMessageTextprivate static shortSECMEC_HAS_NOT_EXPLICITLY_SETprivate shortsecurityMechanismSecurity Mechanism can be specified explicitly either when obtaining a connection via a DriverManager or via Datasource.private static longserialVersionUIDprivate java.lang.StringserverNameprivate booleanshutdownDatabaseSet to true if the database should be shutdown.static intSSL_BASICThe constant indicating that SSL encryption will be used.private static java.lang.StringSSL_BASIC_STRstatic intSSL_OFFThe constant indicating that SSL encryption won't be used.private static java.lang.StringSSL_OFF_STRstatic intSSL_PEER_AUTHENTICATIONThe constant indicating that SSL encryption with peer authentication will be used.private static java.lang.StringSSL_PEER_AUTHENTICATION_STRprivate intsslModestatic shortSTRONG_PASSWORD_SUBSTITUTE_SECURITYSee documentation atUSER_ONLY_SECURITYstatic intTRACE_ALLSee documentation atTRACE_NONE.static intTRACE_CONNECTION_CALLSSee documentation atTRACE_NONE.static intTRACE_CONNECTSSee documentation atTRACE_NONE.static intTRACE_DIAGNOSTICSSee documentation atTRACE_NONE.static intTRACE_DRIVER_CONFIGURATIONSee documentation atTRACE_NONE.static intTRACE_NONEThe client server protocol can be traced.static intTRACE_PARAMETER_META_DATASee documentation atTRACE_NONE.static intTRACE_PROTOCOL_FLOWSSee documentation atTRACE_NONE.static intTRACE_RESULT_SET_CALLSSee documentation atTRACE_NONE.static intTRACE_RESULT_SET_META_DATASee documentation atTRACE_NONE.static intTRACE_STATEMENT_CALLSSee documentation atTRACE_NONE.static intTRACE_XA_CALLSSee documentation atTRACE_NONE.private java.lang.StringtraceDirectoryprivate java.lang.StringtraceFileprivate booleantraceFileAppendprivate inttraceFileSuffixIndex_private inttraceLevelprivate java.lang.StringuserThis property can be overwritten by specifing the username parameter on the DataSource.getConnection() method call.static shortUSER_ONLY_SECURITYThe 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
Constructors Constructor Description BasicClientDataSource40()Creates a simple DERBY data source with default property values for a non-pooling, non-distributed environment.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidcheckBoolean(java.util.Properties set, java.lang.String attribute)private static voidcheckEnumeration(java.util.Properties set, java.lang.String attribute, java.lang.String[] choices)private static LogWritercomputeDncLogWriter(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 LogWritercomputeDncLogWriterForNewConnection(java.io.PrintWriter logWriter, java.lang.String traceDirectory, java.lang.String traceFile, boolean traceFileAppend, int traceLevel, java.lang.String logWriterInUseSuffix, int traceFileSuffixIndex)private LogWritercomputeDncLogWriterForNewConnection(java.lang.String logWriterInUseSuffix)private static java.io.PrintWritercomputePrintWriter(java.io.PrintWriter logWriter, java.lang.String traceDirectory, java.lang.String traceFile, boolean traceFileAppend, java.lang.String logWriterInUseSuffix, int traceFileSuffixIndex)private java.lang.StringconstructUrl()Constructs the JDBC connection URL from the state of the data source.static intgetClientSSLMode(java.util.Properties properties)Returns the SSL mode specified by the property object.java.sql.ConnectiongetConnection()Attempt to establish a database connection in a non-pooling, non-distributed environment.java.sql.ConnectiongetConnection(java.lang.String user, java.lang.String password)Attempt to establish a database connection in a non-pooling, non-distributed environment.java.lang.StringgetConnectionAttributes()private java.sql.ConnectiongetConnectionX(LogWriter dncLogWriter, java.lang.String user, java.lang.String password)java.lang.StringgetCreateDatabase()java.lang.StringgetDatabaseName()java.lang.StringgetDataSourceName()java.lang.StringgetDescription()intgetLoginTimeout()java.io.PrintWritergetLogWriter()java.util.logging.LoggergetParentLogger()java.lang.StringgetPassword()static java.lang.StringgetPassword(java.util.Properties properties)protected javax.sql.PooledConnectiongetPooledConnectionMinion()protected javax.sql.PooledConnectiongetPooledConnectionMinion(java.lang.String user, java.lang.String password)private static javax.sql.PooledConnectiongetPooledConnectionX(LogWriter dncLogWriter, BasicClientDataSource40 ds, java.lang.String user, java.lang.String password)intgetPortNumber()private static java.io.PrintWritergetPrintWriter(java.lang.String fileName, boolean fileAppend)static java.util.PropertiesgetProperties(BasicClientDataSource40 ths)booleangetRetrieveMessageText()static booleangetRetrieveMessageText(java.util.Properties properties)shortgetSecurityMechanism()Return the security mechanism.shortgetSecurityMechanism(java.lang.String password)Return the security mechanism for this datasource object.static shortgetSecurityMechanism(java.util.Properties properties)Return security mechanism if it is set, else upgrade the security mechanism if possible and return the upgraded security mechanismjava.lang.StringgetServerName()java.lang.StringgetShutdownDatabase()java.lang.StringgetSsl()Returns the SSL encryption mode specified for the data source.static intgetSSLModeFromString(java.lang.String s)Parses the string and returns the corresponding constant for the SSL mode denoted.java.lang.StringgetTraceDirectory()(package private) static java.lang.StringgetTraceDirectory(java.util.Properties properties)Check if derby.client.traceDirectory is provided as a JVM property.java.lang.StringgetTraceFile()(package private) static java.lang.StringgetTraceFile(java.util.Properties properties)booleangetTraceFileAppend()(package private) static booleangetTraceFileAppend(java.util.Properties properties)intgetTraceLevel()(package private) static intgetTraceLevel(java.util.Properties properties)Check if derby.client.traceLevel is provided as a JVM property.private static shortgetUpgradedSecurityMechanism(java.lang.String password)This method has logic to upgrade security mechanism to a better (more secure) one if it is possible.java.lang.StringgetUser()static java.lang.StringgetUser(java.util.Properties properties)protected javax.sql.XAConnectiongetXAConnectionMinion()protected javax.sql.XAConnectiongetXAConnectionMinion(java.lang.String user, java.lang.String password)private static javax.sql.XAConnectiongetXAConnectionX(LogWriter dncLogWriter, BasicClientDataSource40 ds, java.lang.String user, java.lang.String password)Method that establishes the initial physical connection using DS properties instead of CPDS properties.private voidhandleConnectionException(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.booleanisWrapperFor(java.lang.Class<?> iface)Check whether this instance wraps an object that implements the interface specified byiface.intmaxStatementsToPool()Returns the maximum number of JDBC prepared statements a connection is allowed to cache.private static booleanparseBoolean(java.lang.String boolString, boolean defaultBool)private static intparseInt(java.lang.String intString, int defaultInt)private static java.lang.StringparseString(java.lang.String string, java.lang.String defaultString)private static java.lang.StringreadSystemProperty(java.lang.String key)Read the value of the passed system property.voidsetConnectionAttributes(java.lang.String prop)Set this property to pass in more Derby specific connection URL attributes.voidsetCreateDatabase(java.lang.String create)Set this property to create a new database.voidsetDatabaseName(java.lang.String databaseName)voidsetDataSourceName(java.lang.String dataSourceName)voidsetDescription(java.lang.String description)voidsetLoginTimeout(int seconds)voidsetLogWriter(java.io.PrintWriter logWriter)voidsetPassword(java.lang.String password)voidsetPortNumber(int portNumber)voidsetRetrieveMessageText(boolean retrieveMessageText)voidsetSecurityMechanism(short securityMechanism)Sets the security mechanism.voidsetServerName(java.lang.String serverName)voidsetShutdownDatabase(java.lang.String shutdown)Set this property if one wishes to shutdown the database identified by databaseName.voidsetSsl(java.lang.String mode)Specifies the SSL encryption mode to use.voidsetTraceDirectory(java.lang.String traceDirectory)voidsetTraceFile(java.lang.String traceFile)voidsetTraceFileAppend(boolean traceFileAppend)voidsetTraceLevel(int traceLevel)voidsetUser(java.lang.String user)(package private) static java.util.PropertiestokenizeAttributes(java.lang.String attributeString, java.util.Properties properties)<T> Tunwrap(java.lang.Class<T> iface)Returnsthisif this class implements the specified interface.private voidupdateDataSourceValues(java.util.Properties prop)The dataSource keeps individual fields for the values that are relevant to the client.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
className__
public static final java.lang.String className__
- See Also:
- Constant Field Values
-
TRACE_NONE
public static final int TRACE_NONE
The 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:
- Constant Field Values
-
TRACE_CONNECTION_CALLS
public static final int TRACE_CONNECTION_CALLS
See documentation atTRACE_NONE.- See Also:
- Constant Field Values
-
TRACE_STATEMENT_CALLS
public static final int TRACE_STATEMENT_CALLS
See documentation atTRACE_NONE.- See Also:
- Constant Field Values
-
TRACE_RESULT_SET_CALLS
public static final int TRACE_RESULT_SET_CALLS
See documentation atTRACE_NONE.- See Also:
- Constant Field Values
-
TRACE_DRIVER_CONFIGURATION
public static final int TRACE_DRIVER_CONFIGURATION
See documentation atTRACE_NONE.- See Also:
- Constant Field Values
-
TRACE_CONNECTS
public static final int TRACE_CONNECTS
See documentation atTRACE_NONE.- See Also:
- Constant Field Values
-
TRACE_PROTOCOL_FLOWS
public static final int TRACE_PROTOCOL_FLOWS
See documentation atTRACE_NONE.- See Also:
- Constant Field Values
-
TRACE_RESULT_SET_META_DATA
public static final int TRACE_RESULT_SET_META_DATA
See documentation atTRACE_NONE.- See Also:
- Constant Field Values
-
TRACE_PARAMETER_META_DATA
public static final int TRACE_PARAMETER_META_DATA
See documentation atTRACE_NONE.- See Also:
- Constant Field Values
-
TRACE_DIAGNOSTICS
public static final int TRACE_DIAGNOSTICS
See documentation atTRACE_NONE.- See Also:
- Constant Field Values
-
TRACE_XA_CALLS
public static final int TRACE_XA_CALLS
See documentation atTRACE_NONE.- See Also:
- Constant Field Values
-
TRACE_ALL
public static final int TRACE_ALL
See documentation atTRACE_NONE.- See Also:
- Constant Field Values
-
propertyDefault_traceLevel
public static final int propertyDefault_traceLevel
See documentation atTRACE_NONE.- See Also:
- Constant Field Values
-
USER_ONLY_SECURITY
public static final short USER_ONLY_SECURITY
The 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:
- Constant Field Values
-
CLEAR_TEXT_PASSWORD_SECURITY
public static final short CLEAR_TEXT_PASSWORD_SECURITY
See documentation atUSER_ONLY_SECURITY- See Also:
- Constant Field Values
-
ENCRYPTED_PASSWORD_SECURITY
public static final short ENCRYPTED_PASSWORD_SECURITY
See documentation atUSER_ONLY_SECURITY- See Also:
- Constant Field Values
-
ENCRYPTED_USER_AND_PASSWORD_SECURITY
public static final short ENCRYPTED_USER_AND_PASSWORD_SECURITY
See documentation atUSER_ONLY_SECURITY- See Also:
- Constant Field Values
-
STRONG_PASSWORD_SUBSTITUTE_SECURITY
public static final short STRONG_PASSWORD_SUBSTITUTE_SECURITY
See documentation atUSER_ONLY_SECURITY- See Also:
- Constant Field Values
-
loginTimeout
private int loginTimeout
The 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
private transient java.io.PrintWriter logWriter
The log writer is declared transient, and is not serialized or stored under JNDI.- See Also:
traceLevel
-
databaseName
private java.lang.String 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
private java.lang.String description
A description of this data source.
-
dataSourceName
private java.lang.String dataSourceName
A data source name; used to name an underlying XADataSource, or ConnectionPoolDataSource when pooling of connections is done.
-
portNumber
private int portNumber
-
serverName
private java.lang.String serverName
-
SSL_OFF
public static final int SSL_OFF
The constant indicating that SSL encryption won't be used.- See Also:
- Constant Field Values
-
SSL_OFF_STR
private static final java.lang.String SSL_OFF_STR
- See Also:
- Constant Field Values
-
SSL_BASIC
public static final int SSL_BASIC
The constant indicating that SSL encryption will be used.- See Also:
- Constant Field Values
-
SSL_BASIC_STR
private static final java.lang.String SSL_BASIC_STR
- See Also:
- Constant Field Values
-
SSL_PEER_AUTHENTICATION
public static final int SSL_PEER_AUTHENTICATION
The constant indicating that SSL encryption with peer authentication will be used.- See Also:
- Constant Field Values
-
SSL_PEER_AUTHENTICATION_STR
private static final java.lang.String SSL_PEER_AUTHENTICATION_STR
- See Also:
- Constant Field Values
-
user
private java.lang.String 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 ownpasswordproperty. 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:
- Constant Field Values
-
securityMechanism
private short securityMechanism
Security 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
private java.lang.String traceFile
-
traceFileSuffixIndex_
private transient int traceFileSuffixIndex_
-
traceDirectory
private java.lang.String traceDirectory
-
traceFileAppend
private boolean traceFileAppend
-
password
private java.lang.String password
-
sslMode
private int sslMode
-
createDatabase
private boolean createDatabase
Set to true if the database should be created.
-
shutdownDatabase
private boolean shutdownDatabase
Set to true if the database should be shutdown.
-
connectionAttributes
private java.lang.String connectionAttributes
-
traceLevel
private int traceLevel
-
-
Constructor Detail
-
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 Detail
-
setLoginTimeout
public void setLoginTimeout(int seconds)
- Specified by:
setLoginTimeoutin interfacejavax.sql.CommonDataSource- Specified by:
setLoginTimeoutin interfacejavax.sql.DataSource
-
getLoginTimeout
public int getLoginTimeout()
- Specified by:
getLoginTimeoutin interfacejavax.sql.CommonDataSource- Specified by:
getLoginTimeoutin interfacejavax.sql.DataSource
-
setLogWriter
public void setLogWriter(java.io.PrintWriter logWriter)
- Specified by:
setLogWriterin interfacejavax.sql.CommonDataSource- Specified by:
setLogWriterin interfacejavax.sql.DataSource
-
getLogWriter
public java.io.PrintWriter getLogWriter()
- Specified by:
getLogWriterin interfacejavax.sql.CommonDataSource- Specified by:
getLogWriterin interfacejavax.sql.DataSource
-
getSSLModeFromString
public static int getSSLModeFromString(java.lang.String s) throws SqlExceptionParses 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_OFFis returned. - Throws:
SqlException- if the string has an invalid value
-
getClientSSLMode
public static int getClientSSLMode(java.util.Properties properties) throws SqlExceptionReturns 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_OFFif the SSL attribute isn't specified. - Throws:
SqlException- if an invalid value for the SSL mode is specified in the property object
-
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
private 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
static java.lang.String getTraceFile(java.util.Properties properties)
-
getTraceDirectory
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
-
readSystemProperty
private static java.lang.String readSystemProperty(java.lang.String key)
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
static boolean getTraceFileAppend(java.util.Properties properties)
-
getPassword
public static java.lang.String getPassword(java.util.Properties properties)
-
setPassword
public void setPassword(java.lang.String password)
- Specified by:
setPasswordin interfaceClientDataSourceInterface
-
getPassword
public java.lang.String getPassword()
- Specified by:
getPasswordin interfaceClientDataSourceInterface
-
computeDncLogWriterForNewConnection
private LogWriter computeDncLogWriterForNewConnection(java.lang.String logWriterInUseSuffix) throws SqlException
- Throws:
SqlException
-
computeDncLogWriterForNewConnection
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) throws SqlException
- Throws:
SqlException
-
computeDncLogWriter
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) throws SqlException
- Throws:
SqlException
-
computePrintWriter
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) throws SqlException- Throws:
SqlException
-
getPrintWriter
private static java.io.PrintWriter getPrintWriter(java.lang.String fileName, boolean fileAppend) throws SqlException- Throws:
SqlException
-
parseBoolean
private static boolean parseBoolean(java.lang.String boolString, boolean defaultBool)
-
parseString
private static java.lang.String parseString(java.lang.String string, java.lang.String defaultString)
-
parseInt
private static int parseInt(java.lang.String intString, int defaultInt)
-
tokenizeAttributes
static java.util.Properties tokenizeAttributes(java.lang.String attributeString, java.util.Properties properties) throws SqlException- Throws:
SqlException
-
checkBoolean
private static void checkBoolean(java.util.Properties set, java.lang.String attribute) throws SqlException- Throws:
SqlException
-
checkEnumeration
private static void checkEnumeration(java.util.Properties set, java.lang.String attribute, java.lang.String[] choices) throws SqlException- Throws:
SqlException
-
setDatabaseName
public void setDatabaseName(java.lang.String databaseName)
- Specified by:
setDatabaseNamein interfaceClientDataSourceInterface
-
getDatabaseName
public java.lang.String getDatabaseName()
- Specified by:
getDatabaseNamein interfaceClientDataSourceInterface
-
setDataSourceName
public void setDataSourceName(java.lang.String dataSourceName)
- Specified by:
setDataSourceNamein interfaceClientDataSourceInterface
-
getDataSourceName
public java.lang.String getDataSourceName()
- Specified by:
getDataSourceNamein interfaceClientDataSourceInterface
-
setDescription
public void setDescription(java.lang.String description)
- Specified by:
setDescriptionin interfaceClientDataSourceInterface
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescriptionin interfaceClientDataSourceInterface
-
setPortNumber
public void setPortNumber(int portNumber)
- Specified by:
setPortNumberin interfaceClientDataSourceInterface
-
getPortNumber
public int getPortNumber()
- Specified by:
getPortNumberin interfaceClientDataSourceInterface
-
setServerName
public void setServerName(java.lang.String serverName)
- Specified by:
setServerNamein interfaceClientDataSourceInterface
-
getServerName
public java.lang.String getServerName()
- Specified by:
getServerNamein interfaceClientDataSourceInterface
-
setUser
public void setUser(java.lang.String user)
- Specified by:
setUserin interfaceClientDataSourceInterface
-
getUser
public java.lang.String getUser()
- Specified by:
getUserin interfaceClientDataSourceInterface
-
setRetrieveMessageText
public void setRetrieveMessageText(boolean retrieveMessageText)
- Specified by:
setRetrieveMessageTextin interfaceClientDataSourceInterface
-
getRetrieveMessageText
public boolean getRetrieveMessageText()
- Specified by:
getRetrieveMessageTextin interfaceClientDataSourceInterface
-
setSecurityMechanism
public void setSecurityMechanism(short securityMechanism)
Sets the security mechanism.- Specified by:
setSecurityMechanismin 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:
getSecurityMechanismin interfaceClientDataSourceInterface- 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.- Specified by:
getSecurityMechanismin interfaceClientDataSourceInterface- Parameters:
password- password of user- Returns:
- the security mechanism
- See Also:
getUpgradedSecurityMechanism(String)
-
setSsl
public void setSsl(java.lang.String mode) throws SqlExceptionSpecifies the SSL encryption mode to use.Valid values are off, basic and peerAuthentication.
- Specified by:
setSslin interfaceClientDataSourceInterface- Parameters:
mode- the SSL mode to use (off, basic or peerAuthentication)- Throws:
SqlException- if the specified mode is invalid
-
getSsl
public java.lang.String getSsl()
Returns the SSL encryption mode specified for the data source.- Specified by:
getSslin interfaceClientDataSourceInterface- Returns:
- off, basic or peerAuthentication.
-
setCreateDatabase
public 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.- Specified by:
setCreateDatabasein 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
public java.lang.String getCreateDatabase()
- Specified by:
getCreateDatabasein interfaceClientDataSourceInterface- Returns:
- "create" if create is set, or null if not
-
setShutdownDatabase
public void setShutdownDatabase(java.lang.String shutdown)
Set this property if one wishes to shutdown the database identified by databaseName.- Specified by:
setShutdownDatabasein interfaceClientDataSourceInterface- Parameters:
shutdown- if set to the string "shutdown", this data source will shutdown the database if it is running.
-
getShutdownDatabase
public java.lang.String getShutdownDatabase()
- Specified by:
getShutdownDatabasein interfaceClientDataSourceInterface- Returns:
- "shutdown" if shutdown is set, or null if not
-
setConnectionAttributes
public 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.- Specified by:
setConnectionAttributesin 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
public java.lang.String getConnectionAttributes()
- Specified by:
getConnectionAttributesin interfaceClientDataSourceInterface- Returns:
- Derby specific connection URL attributes
-
getTraceLevel
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)
- Specified by:
setTraceLevelin interfaceClientDataSourceInterface
-
getTraceLevel
public int getTraceLevel()
- Specified by:
getTraceLevelin interfaceClientDataSourceInterface
-
setTraceFile
public void setTraceFile(java.lang.String traceFile)
- Specified by:
setTraceFilein interfaceClientDataSourceInterface
-
getTraceFile
public java.lang.String getTraceFile()
- Specified by:
getTraceFilein interfaceClientDataSourceInterface
-
setTraceDirectory
public void setTraceDirectory(java.lang.String traceDirectory)
- Specified by:
setTraceDirectoryin interfaceClientDataSourceInterface
-
getTraceDirectory
public java.lang.String getTraceDirectory()
- Specified by:
getTraceDirectoryin interfaceClientDataSourceInterface
-
setTraceFileAppend
public void setTraceFileAppend(boolean traceFileAppend)
- Specified by:
setTraceFileAppendin interfaceClientDataSourceInterface
-
getTraceFileAppend
public boolean getTraceFileAppend()
- Specified by:
getTraceFileAppendin 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
0if caching is disabled (default).
-
updateDataSourceValues
private void updateDataSourceValues(java.util.Properties prop) throws SqlExceptionThe 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
private void handleConnectionException(LogWriter logWriter, SqlException sqle) throws java.sql.SQLException
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 benullsqle- exception to handle- Throws:
java.sql.SQLException- handled exception (if any)
-
constructUrl
private java.lang.String constructUrl()
Constructs the JDBC connection URL from the state of the data source.- Returns:
- The JDBC connection URL.
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLExceptionAttempt to establish a database connection in a non-pooling, non-distributed environment.- Specified by:
getConnectionin interfacejavax.sql.DataSource- Returns:
- a Connection to the database
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
getConnection
public java.sql.Connection getConnection(java.lang.String user, java.lang.String password) throws java.sql.SQLExceptionAttempt to establish a database connection in a non-pooling, non-distributed environment.- Specified by:
getConnectionin interfacejavax.sql.DataSource- Parameters:
user- the database user on whose behalf the Connection is being madepassword- the user's password- Returns:
- a Connection to the database
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
getConnectionX
private java.sql.Connection getConnectionX(LogWriter dncLogWriter, java.lang.String user, java.lang.String password) throws SqlException
- Throws:
SqlException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLExceptionCheck whether this instance wraps an object that implements the interface specified byiface.- Specified by:
isWrapperForin interfacejava.sql.Wrapper- Parameters:
iface- a class defining an interface- Returns:
trueif this instance implementsiface, orfalseotherwise- Throws:
java.sql.SQLException- if an error occurs while determining if this instance implementsiface
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLExceptionReturnsthisif this class implements the specified interface.- Specified by:
unwrapin interfacejava.sql.Wrapper- Parameters:
iface- a class defining an interface- Returns:
- an object that implements the interface
- Throws:
java.sql.SQLException- if no object is found that implements the interface
-
getParentLogger
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException- Specified by:
getParentLoggerin interfacejavax.sql.CommonDataSource- Throws:
java.sql.SQLFeatureNotSupportedException
-
getPooledConnectionMinion
protected final javax.sql.PooledConnection getPooledConnectionMinion() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getPooledConnectionMinion
protected final javax.sql.PooledConnection getPooledConnectionMinion(java.lang.String user, java.lang.String password) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getPooledConnectionX
private static javax.sql.PooledConnection getPooledConnectionX(LogWriter dncLogWriter, BasicClientDataSource40 ds, java.lang.String user, java.lang.String password) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getXAConnectionMinion
protected final javax.sql.XAConnection getXAConnectionMinion() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getXAConnectionMinion
protected final javax.sql.XAConnection getXAConnectionMinion(java.lang.String user, java.lang.String password) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
getXAConnectionX
private static javax.sql.XAConnection getXAConnectionX(LogWriter dncLogWriter, BasicClientDataSource40 ds, java.lang.String user, java.lang.String password) throws java.sql.SQLException
Method that establishes the initial physical connection using DS properties instead of CPDS properties.- Throws:
java.sql.SQLException
-
getProperties
public static java.util.Properties getProperties(BasicClientDataSource40 ths)
-
-