public class BasicEmbeddedDataSource40 extends Object implements DataSource, Serializable, org.apache.derby.jdbc.EmbeddedDataSourceInterface
javax.naming.Referenceable.
The standard attributes provided are, cf. e.g. table
9.1 in the JDBC 4.2 specification.
EmbeddedDataSource,
Serialized Form| Constructor and Description |
|---|
BasicEmbeddedDataSource40()
Constructs a basic embedded data source.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other) |
boolean |
getAttributesAsPassword()
Return the value of the
attributesAsPassword property, cf. |
Connection |
getConnection()
Attempt to establish a database connection.
|
Connection |
getConnection(String username,
String password)
Attempt to establish a database connection with the given username and
password.
|
String |
getConnectionAttributes() |
String |
getCreateDatabase() |
String |
getDatabaseName() |
String |
getDataSourceName() |
String |
getDescription() |
int |
getLoginTimeout()
Gets the maximum time in seconds that this data source can wait
while attempting to connect to a database.
|
PrintWriter |
getLogWriter()
Get the log writer for this data source.
|
Logger |
getParentLogger() |
String |
getPassword() |
String |
getShutdownDatabase() |
String |
getUser() |
int |
hashCode() |
boolean |
isWrapperFor(Class<?> interFace)
Returns false unless
interFace 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(String prop)
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)
Set the database name.
|
void |
setDataSourceName(String dsn)
Set the data source name.
|
void |
setDescription(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(PrintWriter out)
Set the log writer for this data source.
|
void |
setPassword(String password)
Set the
password property for the data source. |
void |
setShutdownDatabase(String shutdown)
Set this property if you wish to shutdown the database identified by
databaseName. |
void |
setUser(String user)
Set the
user property for the data source. |
<T> T |
unwrap(Class<T> iface)
Returns
this if this class implements the specified interface. |
public BasicEmbeddedDataSource40()
public void setDatabaseName(String databaseName)
setDatabaseName in interface org.apache.derby.jdbc.EmbeddedDataSourceInterfacedatabaseName - the name of the databasepublic String getDatabaseName()
getDatabaseName in interface org.apache.derby.jdbc.EmbeddedDataSourceInterfacesetDatabaseName(java.lang.String).public void setDataSourceName(String dsn)
setDataSourceName in interface org.apache.derby.jdbc.EmbeddedDataSourceInterfacedsn - the name of the data sourcepublic String getDataSourceName()
getDataSourceName in interface org.apache.derby.jdbc.EmbeddedDataSourceInterfacesetDataSourceName(java.lang.String).public void setDescription(String desc)
setDescription in interface org.apache.derby.jdbc.EmbeddedDataSourceInterfacedesc - the description of the data sourcepublic String getDescription()
getDescription in interface org.apache.derby.jdbc.EmbeddedDataSourceInterfacesetDescription(java.lang.String).public void setUser(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 org.apache.derby.jdbc.EmbeddedDataSourceInterfaceuser - The userpublic String getUser()
getUser in interface org.apache.derby.jdbc.EmbeddedDataSourceInterfacesetUser(java.lang.String).public void setPassword(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 org.apache.derby.jdbc.EmbeddedDataSourceInterfacepassword - The password in plain textpublic String getPassword()
getPassword in interface org.apache.derby.jdbc.EmbeddedDataSourceInterfacesetPassword(java.lang.String).public int getLoginTimeout()
throws SQLException
setLoginTimeout(int).getLoginTimeout in interface CommonDataSourceSQLException - if a database access error occurs.public void setLoginTimeout(int seconds)
throws SQLException
setLoginTimeout in interface CommonDataSourceseconds - the data source login time limitSQLException - if a database access error occurs.public PrintWriter getLogWriter() throws 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 CommonDataSourceSQLException - if a database-access error occurs.public void setLogWriter(PrintWriter out) throws 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 CommonDataSourceout - the new log writer; to disable, set to nullSQLException - if a database-access error occurs.public void setCreateDatabase(String create)
databaseName)
is assumed to be already existing.setCreateDatabase in interface org.apache.derby.jdbc.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 String getCreateDatabase()
getCreateDatabase in interface org.apache.derby.jdbc.EmbeddedDataSourceInterface"create" if create is set, or null if notpublic void setConnectionAttributes(String prop)
setConnectionAttributes in interface org.apache.derby.jdbc.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 String getConnectionAttributes()
getConnectionAttributes in interface org.apache.derby.jdbc.EmbeddedDataSourceInterfacesetConnectionAttributes(java.lang.String).public void setShutdownDatabase(String shutdown)
databaseName.setShutdownDatabase in interface org.apache.derby.jdbc.EmbeddedDataSourceInterfaceshutdown - if set to the string "shutdown", this
data source will shutdown the database if it is running.public String getShutdownDatabase()
getShutdownDatabase in interface org.apache.derby.jdbc.EmbeddedDataSourceInterface"shutdown" if shutdown is set, or
null if not, cf. setShutdownDatabase(java.lang.String).public 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 org.apache.derby.jdbc.EmbeddedDataSourceInterfaceattributesAsPassword - Use true to encode password
argument as a set of connection attributes in a connection request.public boolean getAttributesAsPassword()
attributesAsPassword property, cf.
setAttributesAsPassword(boolean).getAttributesAsPassword in interface org.apache.derby.jdbc.EmbeddedDataSourceInterfacepublic Connection getConnection() throws SQLException
getConnection in interface DataSourceSQLException - if a database-access error occurs.public Connection getConnection(String username, String password) throws 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 DataSourceusername - the database user on whose behalf the Connection is
being madepassword - the user's passwordSQLException - if a database-access error occurs.public boolean isWrapperFor(Class<?> interFace) throws SQLException
interFace is implemented.isWrapperFor in interface WrapperinterFace - a class defining an interfacetrue if this implements the interface or directly or
indirectly wraps an object that doesSQLException - if an error occurs while determining
whether this is a wrapper for an object with the given interfacepublic <T> T unwrap(Class<T> iface) throws SQLException
this if this class implements the specified interface.unwrap in interface Wrapperiface - a class defining an interfaceSQLException - if no object is found that implements the
interfacepublic Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger in interface CommonDataSourceSQLFeatureNotSupportedExceptionApache Derby 10.14 API Documentation - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.