Top Description Fields Constructors Methods
org.apache.derby.client

public Class BasicClientDataSource

extends Object
implements DataSource, ClientDataSourceInterface, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.derby.client.ClientDataSourceInterface, javax.sql.DataSource, java.sql.Wrapper, javax.sql.CommonDataSource
Annotations
@SuppressWarnings:ResultOfObjectAllocationIgnored
Imports
java.io.BufferedOutputStream, .File, .FileOutputStream, .IOException, .PrintWriter, .Serializable, java.lang.reflect.InvocationTargetException, .Method, .Modifier, java.sql.Connection, .SQLException, .SQLFeatureNotSupportedException, java.util.Locale, .NoSuchElementException, .Properties, .StringTokenizer, java.util.logging.Logger, javax.sql.DataSource, .PooledConnection, .XAConnection, org.apache.derby.client.am.ClientMessageId, .EncryptionManager, .LogWriter, .SQLExceptionFactory, .SqlException, org.apache.derby.client.net.NetConfiguration, .NetLogWriter, org.apache.derby.shared.common.error.ExceptionUtil, org.apache.derby.shared.common.reference.Attribute, .SQLState

This data source is suitable for client/server use of Derby, running on Java 8 Compact Profile 2 or higher.

BasicClientDataSource 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.

These standard attributes are not supported:

The Derby client driver also supports these attributes:

Cloned from BasicClientDataSource40, which is now just an empty shell.

Field Summary

Modifier and TypeField and Description
public static final String
public static final short
private String
private boolean
createDatabase

Set to true if the database should be created.

private String
databaseName

Stores the relational database name, RDBNAME.

private String
dataSourceName

A data source name; used to name an underlying XADataSource, or ConnectionPoolDataSource when pooling of connections is done.

private String
description

A description of this data source.

public static final short
public static final short
private int
loginTimeout

The time in seconds to wait for a connection request on this data source.

private transient PrintWriter
logWriter

The log writer is declared transient, and is not serialized or stored under JNDI.

private String
private int
public static final int
private boolean
private static final short
private short
securityMechanism

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
shutdownDatabase

Set to true if the database should be shutdown.

public static final int
SSL_BASIC

The constant indicating that SSL encryption will be used.

private static final String
public static final int
SSL_OFF

The constant indicating that SSL encryption won't be used.

private static final String
public static final int
SSL_PEER_AUTHENTICATION

The constant indicating that SSL encryption with peer authentication will be used.

private static final String
private int
public static final short
public static final int
TRACE_ALL

See documentation at TRACE_NONE.

public static final int
TRACE_CONNECTION_CALLS

See documentation at TRACE_NONE.

public static final int
TRACE_CONNECTS

See documentation at TRACE_NONE.

public static final int
TRACE_DIAGNOSTICS

See documentation at TRACE_NONE.

public static final int
public static final int
TRACE_NONE

The client server protocol can be traced.

public static final int
public static final int
TRACE_PROTOCOL_FLOWS

See documentation at TRACE_NONE.

public static final int
TRACE_RESULT_SET_CALLS

See documentation at TRACE_NONE.

public static final int
public static final int
TRACE_STATEMENT_CALLS

See documentation at TRACE_NONE.

public static final int
TRACE_XA_CALLS

See documentation at TRACE_NONE.

private String
private String
private boolean
private transient int
private int
private String
user

This property can be overwritten by specifing the username parameter on the DataSource.getConnection() method call.

public static final short
USER_ONLY_SECURITY

Hides org.apache.derby.client.ClientDataSourceInterface.USER_ONLY_SECURITY.

The source security mechanism to use when connecting to a client data source.

Constructor Summary

AccessConstructor and Description
public
BasicClientDataSource()

Creates a simple DERBY data source with default property values for a non-pooling, non-distributed environment.

Method Summary

Modifier and TypeMethod and Description
private 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)

private LogWriter
public static LogWriter
computeDncLogWriterForNewConnection(PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, int traceLevel, String logWriterInUseSuffix, int traceFileSuffixIndex)

private static PrintWriter
computePrintWriter(PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, String logWriterInUseSuffix, int traceFileSuffixIndex)

private String

Returns:

The JDBC connection URL.
constructUrl
()

Constructs the JDBC connection URL from the state of the data source.

public static int

Returns:

A constant indicating the SSL mode to use. Defaults to SSL_OFF if the SSL attribute isn't specified.
getClientSSLMode
(Properties
data source properties
properties
)

Returns the SSL mode specified by the property object.

public Connection

Returns:

a Connection to the database
getConnection
()

Implements javax.sql.DataSource.getConnection.

Attempt to establish a database connection in a non-pooling, non-distributed environment.
public Connection

Returns:

a Connection to the database
getConnection
(String
the database user on whose behalf the Connection is being made
user
,
String
the user's password
password
)

Implements javax.sql.DataSource.getConnection.

Attempt to establish a database connection in a non-pooling, non-distributed environment.
public String

Returns:

Derby specific connection URL attributes
getConnectionAttributes
()

Implements org.apache.derby.client.ClientDataSourceInterface.getConnectionAttributes.

private Connection
getConnectionX(LogWriter dncLogWriter, String user, String password)

public String

Returns:

"create" if create is set, or null if not
getCreateDatabase
()

Implements org.apache.derby.client.ClientDataSourceInterface.getCreateDatabase.

public String
public String
public String
public int
getLoginTimeout()

Implements javax.sql.DataSource.getLoginTimeout.

Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.
public PrintWriter
getLogWriter()

Implements javax.sql.DataSource.getLogWriter.

Retrieves the log writer for this DataSource object.

public Logger
getParentLogger()

Implements javax.sql.CommonDataSource.getParentLogger.

Return the parent Logger of all the Loggers used by this data source.
public static String
getPassword(Properties properties)

public String
protected final PooledConnection
protected final PooledConnection
private static PooledConnection
public int
private static PrintWriter
getPrintWriter(final String fileName, final boolean fileAppend)

public static Properties
public static boolean
public boolean
public static short

Returns:

security mechanism
getSecurityMechanism
(Properties
Look in the properties if securityMechanism is set or not if set, return this security mechanism
properties
)

Return security mechanism if it is set, else upgrade the security mechanism if possible and return the upgraded security mechanism

public short

Returns:

the security mechanism
getSecurityMechanism
()

Implements org.apache.derby.client.ClientDataSourceInterface.getSecurityMechanism.

Return the security mechanism.
public short

Returns:

the security mechanism
getSecurityMechanism
(String
password of user
password
)

Implements org.apache.derby.client.ClientDataSourceInterface.getSecurityMechanism.

Return the security mechanism for this datasource object.
public String
public String

Returns:

"shutdown" if shutdown is set, or null if not
getShutdownDatabase
()

Implements org.apache.derby.client.ClientDataSourceInterface.getShutdownDatabase.

public String

Returns:

off, basic or peerAuthentication.
getSsl
()

Implements org.apache.derby.client.ClientDataSourceInterface.getSsl.

Returns the SSL encryption mode specified for the data source.
public static int

Returns:

A constant indicating the SSL mode denoted by the string. If the string is null, SSL_OFF is returned.
getSSLModeFromString
(String
string denoting the SSL mode
s
)

Parses the string and returns the corresponding constant for the SSL mode denoted.

public static String

Returns:

value of traceDirectory property
getTraceDirectory
(Properties
jdbc url properties
properties
)

Check if derby.client.traceDirectory is provided as a JVM property.

public String
public static String
public String
public static boolean
public boolean
public static int

Returns:

value of traceLevel property
getTraceLevel
(Properties
jdbc url properties
properties
)

Check if derby.client.traceLevel is provided as a JVM property.

public int
private static short

Returns:

upgraded security mechanism if possible
getUpgradedSecurityMechanism
(String
password argument
password
)

This method has logic to upgrade security mechanism to a better (more secure) one if it is possible.

public static String
getUser(Properties properties)

public String
protected final XAConnection
protected final XAConnection
private static XAConnection
getXAConnectionX(LogWriter dncLogWriter, BasicClientDataSource ds, String user, String password)

Method that establishes the initial physical connection using DS properties instead of CPDS properties.

private void
handleConnectionException(LogWriter
log writer, may be null
logWriter
,
SqlException
exception to handle
sqle
)

Handles common error situations that can happen when trying to obtain a physical connection to the server, and which require special handling.

public boolean

Returns:

true if this instance implements iface, or false otherwise
isWrapperFor
(Class<?>
a class defining an interface
iface
)

Implements java.sql.Wrapper.isWrapperFor.

Check whether this instance wraps an object that implements the interface specified by iface.
public int

Returns:

Maximum number of statements to cache, or 0 if caching is disabled (default).
maxStatementsToPool
()

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
parseInt(String intString, int defaultInt)

private static String
parseString(String string, String defaultString)

private static String

Returns:

value of the system property, null if there is no permission to read the property
readSystemProperty
(final String
name of the system property
key
)

Read the value of the passed system property.

public void
setConnectionAttributes(String
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.
prop
)

Implements org.apache.derby.client.ClientDataSourceInterface.setConnectionAttributes.

Set this property to pass in more Derby specific connection URL attributes.
public void
setCreateDatabase(String
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.
create
)

Implements org.apache.derby.client.ClientDataSourceInterface.setCreateDatabase.

Set this property to create a new database.
public synchronized void
public synchronized void
public synchronized void
public synchronized void
setLoginTimeout(int
the data source login time limit
seconds
)

Implements javax.sql.DataSource.setLoginTimeout.

Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.

public synchronized void
setLogWriter(PrintWriter
the new log writer; to disable logging, set to null
logWriter
)

Implements javax.sql.DataSource.setLogWriter.

Sets the log writer for this DataSource object to the given java.io.PrintWriter object.

public synchronized void
public synchronized void
public synchronized void
public synchronized void
setSecurityMechanism(short
to set
securityMechanism
)

Implements org.apache.derby.client.ClientDataSourceInterface.setSecurityMechanism.

Sets the security mechanism.
public synchronized void
public void
setShutdownDatabase(String
if set to the string "shutdown", this data source will shutdown the database if it is running.
shutdown
)

Implements org.apache.derby.client.ClientDataSourceInterface.setShutdownDatabase.

Set this property if one wishes to shutdown the database identified by databaseName.
public void
setSsl(String
the SSL mode to use (off, basic or peerAuthentication)
mode
)

Implements org.apache.derby.client.ClientDataSourceInterface.setSsl.

Specifies the SSL encryption mode to use.
public synchronized void
public synchronized void
public synchronized void
public synchronized void
public synchronized void
public static Properties
tokenizeAttributes(String attributeString, Properties properties)

public <T> T

Returns:

an object that implements the interface
unwrap
(Class<T>
a class defining an interface
iface
)

Implements java.sql.Wrapper.unwrap.

Returns this if this class implements the specified interface.
private void
updateDataSourceValues(Properties prop)

The dataSource keeps individual fields for the values that are relevant to the client.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait