public final class EmbeddedSimpleDataSource
extends java.lang.Object
implements javax.sql.DataSource
EmbeddedSimpleDataSource automatically supports the correct JDBC specification version for the Java Virtual Machine's environment.
EmbeddedDataSource
Constructor and Description |
---|
EmbeddedSimpleDataSource()
No-arg constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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() |
java.lang.String |
getShutdownDatabase() |
java.lang.String |
getUser() |
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 one wishes to shutdown the database identified by
databaseName.
|
void |
setUser(java.lang.String user)
Set the
user property for the data source. |
public int getLoginTimeout() throws java.sql.SQLException
getLoginTimeout
in interface javax.sql.DataSource
java.sql.SQLException
- if a database access error occurs.public void setLoginTimeout(int seconds) throws java.sql.SQLException
Derby ignores this property.
setLoginTimeout
in interface javax.sql.DataSource
seconds
- the data source login time limitjava.sql.SQLException
- if a database access error occurs.public java.io.PrintWriter getLogWriter() throws java.sql.SQLException
The log writer is a character output stream to which all logging and tracing messages for this data source object instance will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the 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.DataSource
java.sql.SQLException
- if a database-access error occurs.public void setLogWriter(java.io.PrintWriter out) throws java.sql.SQLException
The log writer is a character output stream to which all logging and tracing messages for this data source object instance will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the 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.DataSource
out
- the new log writer; to disable, set to nulljava.sql.SQLException
- if a database-access error occurs.public final void setDatabaseName(java.lang.String databaseName)
databaseName
- the name of the databasepublic java.lang.String getDatabaseName()
public final void setDataSourceName(java.lang.String dsn)
dsn
- the name of the data sourcepublic final java.lang.String getDataSourceName()
public final void setDescription(java.lang.String desc)
desc
- the description of the data sourcepublic final java.lang.String getDescription()
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.public final java.lang.String getUser()
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.public final java.lang.String getPassword()
public final void setCreateDatabase(java.lang.String create)
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.public final java.lang.String getCreateDatabase()
public final void setShutdownDatabase(java.lang.String shutdown)
shutdown
- if set to the string "shutdown", this data source will
shutdown the database if it is running.public final java.lang.String getShutdownDatabase()
public final void setConnectionAttributes(java.lang.String prop)
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's documentation for complete list.
public final java.lang.String getConnectionAttributes()
public final java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
- if a database-access error occurs.public final java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
username
- the database user on whose behalf the Connection is being madepassword
- the user's passwordjava.sql.SQLException
- if a database-access error occurs.Apache Derby 10.10 API Documentation - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.