public abstract class EmbeddedBaseDataSource extends java.lang.Object implements java.io.Serializable, EmbeddedDataSourceInterface
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
attributesAsPassword
Set password to be a set of connection attributes.
|
protected java.lang.String |
connectionAttributes
Derby specific connection attributes.
|
protected java.lang.String |
createDatabase
Set to "create" if the database should be created.
|
protected java.lang.String |
databaseName |
protected java.lang.String |
dataSourceName |
protected java.lang.String |
description |
protected InternalDriver |
driver |
protected java.lang.String |
jdbcurl |
protected int |
loginTimeout |
private java.lang.String |
password |
private java.io.PrintWriter |
printer
instance variables that will not be serialized
|
private static long |
serialVersionUID |
private java.lang.String |
shortDatabaseName
shortDatabaseName has attributes of databaseName stripped
|
protected java.lang.String |
shutdownDatabase
Set to "shutdown" if the database should be shutdown.
|
private java.lang.String |
user |
| Constructor and Description |
|---|
EmbeddedBaseDataSource()
No-arg constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object p0) |
(package private) InternalDriver |
findDriver() |
boolean |
getAttributesAsPassword()
Return the value of the
attributesAsPassword property, cf. |
java.sql.Connection |
getConnection()
Attempt to establish a database connection.
|
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password)
Attempt to establish a database connection with the given username and
password.
|
(package private) java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password,
boolean requestPassword) |
java.lang.String |
getConnectionAttributes() |
java.lang.String |
getCreateDatabase() |
java.lang.String |
getDatabaseName() |
java.lang.String |
getDataSourceName() |
java.lang.String |
getDescription() |
int |
getLoginTimeout()
Gets the maximum time in seconds that this data source can wait
while attempting to connect to a database.
|
java.io.PrintWriter |
getLogWriter()
Get the log writer for this data source.
|
java.lang.String |
getPassword() |
protected java.lang.String |
getShortDatabaseName() |
java.lang.String |
getShutdownDatabase() |
java.lang.String |
getUser() |
boolean |
isWrapperFor(java.lang.Class<?> iface)
Returns false unless
interfaces is implemented. |
void |
setAttributesAsPassword(boolean attributesAsPassword)
Set
attributeAsPassword property to enable passing connection
request attributes in the password argument of
getConnection(String,String). |
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)
Set the database name.
|
void |
setDataSourceName(java.lang.String dsn)
Set the data source name.
|
void |
setDescription(java.lang.String desc)
Set the data source descripton.
|
void |
setLoginTimeout(int seconds)
Sets the maximum time in seconds that this data source will wait
while attempting to connect to a database.
|
void |
setLogWriter(java.io.PrintWriter out)
Set the log writer for this data source.
|
void |
setPassword(java.lang.String password)
Set the
password property for the data source. |
void |
setShutdownDatabase(java.lang.String shutdown)
Set this property if you wish to shutdown the database identified by
databaseName. |
protected static ResourceAdapter |
setupResourceAdapter(EmbeddedXADataSourceInterface ds,
ResourceAdapter ra,
java.lang.String user,
java.lang.String password,
boolean requestPassword) |
void |
setUser(java.lang.String user)
Set the
user property for the data source. |
<T> T |
unwrap(java.lang.Class<T> iface)
Returns
this if this class implements the specified interface. |
protected void |
update() |
private static final long serialVersionUID
protected java.lang.String description
protected java.lang.String dataSourceName
protected java.lang.String databaseName
protected java.lang.String connectionAttributes
protected java.lang.String createDatabase
protected java.lang.String shutdownDatabase
protected boolean attributesAsPassword
private java.lang.String shortDatabaseName
private java.lang.String password
private java.lang.String user
protected int loginTimeout
private transient java.io.PrintWriter printer
protected transient java.lang.String jdbcurl
protected transient InternalDriver driver
public final void setDatabaseName(java.lang.String databaseName)
setDatabaseName in interface EmbeddedDataSourceInterfacedatabaseName - the name of the databasepublic java.lang.String getDatabaseName()
getDatabaseName in interface EmbeddedDataSourceInterfacesetDatabaseName(java.lang.String).protected java.lang.String getShortDatabaseName()
public final void setDataSourceName(java.lang.String dsn)
setDataSourceName in interface EmbeddedDataSourceInterfacedsn - the name of the data sourcepublic final java.lang.String getDataSourceName()
getDataSourceName in interface EmbeddedDataSourceInterfacesetDataSourceName(java.lang.String).public final void setDescription(java.lang.String desc)
setDescription in interface EmbeddedDataSourceInterfacedesc - the description of the data sourcepublic final java.lang.String getDescription()
getDescription in interface EmbeddedDataSourceInterfacesetDescription(java.lang.String).public final void setUser(java.lang.String user)
user property for the data source.
This is user name for any data source getConnection() call
that takes no arguments.setUser in interface EmbeddedDataSourceInterfacepublic final java.lang.String getUser()
getUser in interface EmbeddedDataSourceInterfacesetUser(java.lang.String).public final void setPassword(java.lang.String password)
password property for the data source.
This is user's password for any data source getConnection() call
that takes no arguments.setPassword in interface EmbeddedDataSourceInterfacepublic final java.lang.String getPassword()
getPassword in interface EmbeddedDataSourceInterfacesetPassword(java.lang.String).public int getLoginTimeout()
throws java.sql.SQLException
setLoginTimeout(int).getLoginTimeout in interface javax.sql.CommonDataSourcejava.sql.SQLException - if a database access error occurs.public void setLoginTimeout(int seconds)
throws java.sql.SQLException
setLoginTimeout in interface javax.sql.CommonDataSourceseconds - the data source login time limitjava.sql.SQLException - if a database access error occurs.public java.io.PrintWriter getLogWriter()
throws java.sql.SQLException
java.sql.Drivermanager class.
When a data source object is created the log writer is
initially null, in other words, logging is disabled.getLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLException - if a database-access error occurs.public void setLogWriter(java.io.PrintWriter out)
throws java.sql.SQLException
java.sql.Drivermanager class.
When a data source object is created the log writer is
initially null, in other words, logging is disabled.setLogWriter in interface javax.sql.CommonDataSourceout - the new log writer; to disable, set to nulljava.sql.SQLException - if a database-access error occurs.protected void update()
public final void setCreateDatabase(java.lang.String create)
databaseName)
is assumed to be already existing.setCreateDatabase in interface EmbeddedDataSourceInterfacecreate - 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 EmbeddedDataSourceInterface"create" if create is set, or null if notInternalDriver findDriver() throws java.sql.SQLException
java.sql.SQLExceptionpublic final void setConnectionAttributes(java.lang.String prop)
setConnectionAttributes in interface EmbeddedDataSourceInterfaceprop - 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 the Derby documentation for complete list.public final java.lang.String getConnectionAttributes()
getConnectionAttributes in interface EmbeddedDataSourceInterfacesetConnectionAttributes(java.lang.String).public final void setShutdownDatabase(java.lang.String shutdown)
databaseName.setShutdownDatabase in interface EmbeddedDataSourceInterfaceshutdown - 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 EmbeddedDataSourceInterface"shutdown" if shutdown is set, or
null if not, cf. setShutdownDatabase(java.lang.String).public final void setAttributesAsPassword(boolean attributesAsPassword)
attributeAsPassword property to enable passing connection
request attributes in the password argument of
getConnection(String,String).
If the property is set to true then the password
argument of the getConnection(String, String)
method call is taken to be a list of connection attributes with the
same format as the connectionAttributes property.setAttributesAsPassword in interface EmbeddedDataSourceInterfaceattributesAsPassword - Use true to encode password
argument as a set of connection attributes in a connection request.public final boolean getAttributesAsPassword()
attributesAsPassword property, cf.
setAttributesAsPassword(boolean).getAttributesAsPassword in interface EmbeddedDataSourceInterfacepublic boolean equals(java.lang.Object p0)
equals in class java.lang.Objectpublic 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 username,
java.lang.String password)
throws java.sql.SQLException
attributeAsPassword property is set to true
then the password argument is taken to be a list of connection
attributes with the same format as the connectionAttributes
property.getConnection in interface javax.sql.DataSourceusername - the database user on whose behalf the Connection is
being madepassword - the user's passwordjava.sql.SQLException - if a database-access error occurs.final java.sql.Connection getConnection(java.lang.String username,
java.lang.String password,
boolean requestPassword)
throws java.sql.SQLException
requestPassword - Use true if the password came from the
getConnection() call.java.sql.SQLExceptionpublic boolean isWrapperFor(java.lang.Class<?> iface)
throws java.sql.SQLException
interfaces is implemented.isWrapperFor in interface java.sql.Wrapperiface - a class defining an interfacetrue if this implements the interface or directly or
indirectly wraps an object that doesjava.sql.SQLException - if an error occurs while determining
whether this is a wrapper for an object with the given interfacepublic <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 static ResourceAdapter setupResourceAdapter(EmbeddedXADataSourceInterface ds, ResourceAdapter ra, java.lang.String user, java.lang.String password, boolean requestPassword) throws java.sql.SQLException
java.sql.SQLExceptionApache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.