java.lang.Object
org.apache.derby.jdbc.BasicEmbeddedDataSource40
- All Implemented Interfaces:
- Serializable,- Wrapper,- CommonDataSource,- DataSource,- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Direct Known Subclasses:
- BasicEmbeddedConnectionPoolDataSource40,- BasicEmbeddedXADataSource40,- org.apache.derby.jdbc.ReferenceableDataSource
public class BasicEmbeddedDataSource40
extends Object
implements DataSource, Serializable, org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
This data source is suitable for an application using embedded Derby,
 running on Java 8 Compact Profile 2 or higher.
 
 BasicEmbeddedDataSource40 is similar to EmbeddedDataSource, but does
 not support JNDI naming, i.e. it does not implement
 
See the specific Derby DataSource implementation for details on their meaning. See also the JDBC specifications for more details.
javax.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
- portNumber
- roleName
- serverName
- loginTimeout @see javax.sql.CommonDataSource set/get
- logWriter @see javax.sql.CommonDataSource set/get
- createDatabase
- connectionAttributes
- shutdownDatabase
- attributesAsPassword
See the specific Derby DataSource implementation for details on their meaning. See also the JDBC specifications for more details.
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanbooleanReturn the value of theattributesAsPasswordproperty, cf.Attempt to establish a database connection.getConnection(String username, String password) Attempt to establish a database connection with the given username and password.final ConnectiongetConnection(String username, String password, boolean requestPassword) Get a user connection: minion method.intGets the maximum time in seconds that this data source can wait while attempting to connect to a database.Get the log writer for this data source.getUser()inthashCode()booleanisWrapperFor(Class<?> interFace) Returns false unlessinterFaceis implemented.voidsetAttributesAsPassword(boolean attributesAsPassword) SetattributeAsPasswordproperty to enable passing connection request attributes in the password argument ofgetConnection(String,String).voidSet this property to pass in more Derby specific connection URL attributes.voidsetCreateDatabase(String create) Set this property to create a new database.voidsetDatabaseName(String databaseName) Set the database name.voidsetDataSourceName(String dsn) Set the data source name.voidsetDescription(String desc) Set the data source descripton.voidsetLoginTimeout(int seconds) Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.voidsetLogWriter(PrintWriter out) Set the log writer for this data source.voidsetPassword(String password) Set thepasswordproperty for the data source.voidsetShutdownDatabase(String shutdown) Set this property if you wish to shutdown the database identified bydatabaseName.voidSet theuserproperty for the data source.<T> TReturnsthisif this class implements the specified interface.Methods inherited from class java.lang.ObjectgetClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.sql.CommonDataSourcecreateShardingKeyBuilderMethods inherited from interface javax.sql.DataSourcecreateConnectionBuilder
- 
Constructor Details- 
BasicEmbeddedDataSource40public BasicEmbeddedDataSource40()Constructs a basic embedded data source. See the class Javadoc.
 
- 
- 
Method Details- 
setDatabaseNameSet the database name. Setting this property is mandatory. If a database named wombat at g:/db needs to be accessed, database name should be set to "g:/db/wombat". The database will be booted if it is not already running in the system.- Specified by:
- setDatabaseNamein interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Parameters:
- databaseName- the name of the database
 
- 
getDatabaseName- Specified by:
- getDatabaseNamein interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Returns:
- the database name set by setDatabaseName(java.lang.String).
 
- 
setDataSourceNameSet the data source name. The property is not mandatory. It is used for informational purposes only.- Specified by:
- setDataSourceNamein interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Parameters:
- dsn- the name of the data source
 
- 
getDataSourceName- Specified by:
- getDataSourceNamein interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Returns:
- data source name as set in setDataSourceName(java.lang.String).
 
- 
setDescriptionSet the data source descripton. This property is not mandatory. It is used for informational purposes only.- Specified by:
- setDescriptionin interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Parameters:
- desc- the description of the data source
 
- 
getDescription- Specified by:
- getDescriptionin interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Returns:
- the description as set in setDescription(java.lang.String).
 
- 
setUserSet theuserproperty for the data source. This is user name for any data sourcegetConnection()call that takes no arguments.- Specified by:
- setUserin interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Parameters:
- user- The user
 
- 
getUser- Specified by:
- getUserin interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Returns:
- the user name as set by setUser(java.lang.String).
 
- 
setPasswordSet thepasswordproperty for the data source. This is user's password for any data sourcegetConnection()call that takes no arguments.- Specified by:
- setPasswordin interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Parameters:
- password- The password in plain text
 
- 
getPassword- Specified by:
- getPasswordin interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Returns:
- the password as set in setPassword(java.lang.String).
 
- 
getLoginTimeoutGets the maximum time in seconds that this data source can wait while attempting to connect to a database. A value of zero means that the timeout is the default system timeout if there is one; otherwise it means that there is no timeout. When a data source object is created, the login timeout is initially zero. SeesetLoginTimeout(int).- Specified by:
- getLoginTimeoutin interface- CommonDataSource
- Specified by:
- getLoginTimeoutin interface- DataSource
- Returns:
- the data source login time limit
- Throws:
- SQLException- if a database access error occurs.
 
- 
setLoginTimeoutSets the maximum time in seconds that this data source will wait while attempting to connect to a database. A value of zero specifies that the timeout is the default system timeout if there is one; otherwise it specifies that there is no timeout. When a data source object is created, the login timeout is initially zero. Derby currently ignores this property.- Specified by:
- setLoginTimeoutin interface- CommonDataSource
- Specified by:
- setLoginTimeoutin interface- DataSource
- Parameters:
- seconds- the data source login time limit
- Throws:
- SQLException- if a database access error occurs.
 
- 
getLogWriterGet the log writer for this data source. 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 thejava.sql.Drivermanagerclass. When a data source object is created the log writer is initially null, in other words, logging is disabled.- Specified by:
- getLogWriterin interface- CommonDataSource
- Specified by:
- getLogWriterin interface- DataSource
- Returns:
- the log writer for this data source, null if disabled
- Throws:
- SQLException- if a database-access error occurs.
 
- 
setLogWriterSet the log writer for this data source. 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 thejava.sql.Drivermanagerclass. When a data source object is created the log writer is initially null, in other words, logging is disabled.- Specified by:
- setLogWriterin interface- CommonDataSource
- Specified by:
- setLogWriterin interface- DataSource
- Parameters:
- out- the new log writer; to disable, set to null
- Throws:
- SQLException- if a database-access error occurs.
 
- 
setCreateDatabaseSet this property to create a new database. If this property is not set, the database (identified bydatabaseName) is assumed to be already existing.- Specified by:
- setCreateDatabasein interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- 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- Specified by:
- getCreateDatabasein interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Returns:
- The string "create"if create is set, ornullif not
 
- 
setConnectionAttributesSet 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 connection attributes. Conflicting settings in connection attributes and properties of the DataSource will lead to unexpected behaviour.- Specified by:
- setConnectionAttributesin interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- 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 the Derby documentation for complete list.
 
- 
getConnectionAttributes- Specified by:
- getConnectionAttributesin interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Returns:
- the Derby specific connection URL attributes, see
 setConnectionAttributes(java.lang.String).
 
- 
setShutdownDatabaseSet this property if you wish to shutdown the database identified bydatabaseName.- Specified by:
- setShutdownDatabasein interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Parameters:
- shutdown- if set to the string- "shutdown", this data source will shutdown the database if it is running.
 
- 
getShutdownDatabase- Specified by:
- getShutdownDatabasein interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Returns:
- the string "shutdown"if shutdown is set, or null if not, cf.setShutdownDatabase(java.lang.String).
 
- 
setAttributesAsPasswordpublic void setAttributesAsPassword(boolean attributesAsPassword) SetattributeAsPasswordproperty to enable passing connection request attributes in the password argument ofgetConnection(String,String). If the property is set totruethen thepasswordargument of thegetConnection(String, String)method call is taken to be a list of connection attributes with the same format as theconnectionAttributesproperty.- Specified by:
- setAttributesAsPasswordin interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Parameters:
- attributesAsPassword- Use- trueto encode password argument as a set of connection attributes in a connection request.
 
- 
getAttributesAsPasswordpublic boolean getAttributesAsPassword()Return the value of theattributesAsPasswordproperty, cf.setAttributesAsPassword(boolean).- Specified by:
- getAttributesAsPasswordin interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Returns:
- the value
 
- 
equals
- 
hashCodepublic int hashCode()
- 
getConnectionAttempt to establish a database connection.- Specified by:
- getConnectionin interface- DataSource
- Returns:
- a Connection to the database
- Throws:
- SQLException- if a database-access error occurs.
 
- 
getConnectionAttempt to establish a database connection with the given username and password. If theattributeAsPasswordproperty is set to true then the password argument is taken to be a list of connection attributes with the same format as theconnectionAttributesproperty.- Specified by:
- getConnectionin interface- DataSource
- Parameters:
- username- the database user on whose behalf the Connection is being made
- password- the user's password
- Returns:
- a Connection to the database
- Throws:
- SQLException- if a database-access error occurs.
 
- 
getConnectionpublic final Connection getConnection(String username, String password, boolean requestPassword) throws SQLException Get a user connection: minion method.- Specified by:
- getConnectionin interface- org.apache.derby.iapi.jdbc.EmbeddedDataSourceInterface
- Parameters:
- username- the user name
- password- the password
- requestPassword-- trueif the password came from the getConnection() call with user and password arguments..
- Returns:
- user connection
- Throws:
- SQLException
 
- 
isWrapperForReturns false unlessinterFaceis implemented.- Specified by:
- isWrapperForin interface- Wrapper
- Parameters:
- interFace- a class defining an interface
- Returns:
- trueif this implements the interface or directly or indirectly wraps an object that does
- Throws:
- SQLException- if an error occurs while determining whether this is a wrapper for an object with the given interface
 
- 
unwrapReturnsthisif this class implements the specified interface.- Specified by:
- unwrapin interface- Wrapper
- Parameters:
- iface- a class defining an interface
- Returns:
- an object that implements the interface
- Throws:
- SQLException- if no object is found that implements the interface
 
- 
getParentLogger- Specified by:
- getParentLoggerin interface- CommonDataSource
- Throws:
- SQLFeatureNotSupportedException
 
 
-