public class WrappedCdmDataSource extends java.lang.Object implements ICdmDataSource
DataSource
to an
ICdmDataSource
. As the former is a very limited interface it is not possible
to implement all methods of ICdmDataSource
. However, the aim is
to implement all those methods which are usually needed to work with a datasource
which represents a connection to a database such as transaction handling and
sending queries.
Those methods which are not supported by this wrapper class will throw an xxx
exception.Constructor and Description |
---|
WrappedCdmDataSource(javax.sql.DataSource datasource) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkConnection()
Tests, if a database connection can be established.
|
void |
closeOpenConnections()
Closes any open connections to this CDM Source
|
void |
commitTransaction()
Commits the transaction for the given datasource.
|
java.sql.ResultSet |
executeQuery(java.lang.String query)
Executes a query and returns the ResultSet.
|
int |
executeUpdate(java.lang.String sqlUpdate)
Executes an update
|
java.sql.Connection |
getConnection() |
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password) |
java.lang.String |
getConnectionMessage()
Returns the message to display when connecting to this CDM Source
|
java.lang.String |
getDatabase() |
DatabaseTypeEnum |
getDatabaseType()
Returns the database type of the data source.
|
org.springframework.beans.factory.config.BeanDefinition |
getDatasourceBean()
Returns a BeanDefinition object of type DataSource that contains
datsource properties (url, username, password, ...)
|
java.lang.String |
getDbSchemaVersion()
Returns the CDM schema version of this CDM Source
|
java.lang.String |
getFilePath() |
org.springframework.beans.factory.config.BeanDefinition |
getHibernatePropertiesBean(DbSchemaValidation hbm2dll) |
org.springframework.beans.factory.config.BeanDefinition |
getHibernatePropertiesBean(DbSchemaValidation hbm2dll,
java.lang.Boolean showSql,
java.lang.Boolean formatSql,
java.lang.Boolean registerSearchListener,
java.lang.Class<? extends org.hibernate.cache.spi.RegionFactory> cacheProviderClass)
Deprecated.
|
org.springframework.beans.factory.config.BeanDefinition |
getHibernatePropertiesBean(DbSchemaValidation hbm2dll,
HibernateConfiguration hibernateConfig) |
int |
getLoginTimeout() |
java.io.PrintWriter |
getLogWriter() |
java.sql.DatabaseMetaData |
getMetaData()
Returns
DatabaseMetaData for this datasource. |
java.util.Map<CdmMetaDataPropertyName,java.lang.String> |
getMetaDataMap() |
H2Mode |
getMode() |
java.lang.String |
getName()
Returns the name representation of this CDM Source
|
java.util.logging.Logger |
getParentLogger() |
java.lang.String |
getPassword() |
int |
getPort()
Returns the port on which this CDM Source is listening
|
java.lang.String |
getServer()
Returns the server (string representation) where this CDM Source resides
|
java.lang.Object |
getSingleValue(java.lang.String query)
Returns the first value of the first row of a result set.
If no row exists in the result set null is returned. |
java.lang.String |
getUsername() |
boolean |
isDbEmpty()
Checks whether the underlying database is empty
|
boolean |
isWrapperFor(java.lang.Class<?> iface) |
void |
rollback()
Rolls the connection back.
|
void |
setDatabase(java.lang.String database) |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(java.io.PrintWriter out) |
void |
setMode(H2Mode h2Mode) |
void |
setName(java.lang.String name)
Sets the name representation of this CDM Source
|
void |
setPassword(java.lang.String password) |
void |
setPort(int port)
Sets the port on which this CDM Source is listening
|
void |
setServer(java.lang.String server)
Sets the server (string representation) where this CDM Source resides
|
void |
setUsername(java.lang.String username) |
void |
startTransaction()
Starts a transaction for the given datasource.
|
boolean |
testConnection()
Tests, if a database connection can be established.
|
<T> T |
unwrap(java.lang.Class<T> iface) |
public WrappedCdmDataSource(javax.sql.DataSource datasource)
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public java.io.PrintWriter getLogWriter() throws java.sql.SQLException
getLogWriter
in interface javax.sql.CommonDataSource
java.sql.SQLException
public void setLogWriter(java.io.PrintWriter out) throws java.sql.SQLException
setLogWriter
in interface javax.sql.CommonDataSource
java.sql.SQLException
public void setLoginTimeout(int seconds) throws java.sql.SQLException
setLoginTimeout
in interface javax.sql.CommonDataSource
java.sql.SQLException
public int getLoginTimeout() throws java.sql.SQLException
getLoginTimeout
in interface javax.sql.CommonDataSource
java.sql.SQLException
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
getParentLogger
in interface javax.sql.CommonDataSource
java.sql.SQLFeatureNotSupportedException
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
unwrap
in interface java.sql.Wrapper
java.sql.SQLException
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
isWrapperFor
in interface java.sql.Wrapper
java.sql.SQLException
public java.lang.String getName()
ICdmSource
getName
in interface ICdmSource
public void setName(java.lang.String name)
ICdmSource
setName
in interface ICdmSource
public java.lang.String getServer()
ICdmSource
getServer
in interface ICdmSource
public void setServer(java.lang.String server)
ICdmSource
setServer
in interface ICdmSource
public int getPort()
ICdmSource
getPort
in interface ICdmSource
public void setPort(int port)
ICdmSource
setPort
in interface ICdmSource
public java.lang.String getDbSchemaVersion() throws CdmSourceException
ICdmSource
getDbSchemaVersion
in interface ICdmSource
CdmSourceException
- if any underlying errorpublic boolean isDbEmpty() throws CdmSourceException
ICdmSource
isDbEmpty
in interface ICdmSource
CdmSourceException
public boolean checkConnection() throws CdmSourceException
ICdmSource
checkConnection
in interface ICdmSource
CdmSourceException
- if any underlying errorpublic java.lang.String getConnectionMessage()
ICdmSource
getConnectionMessage
in interface ICdmSource
public void closeOpenConnections()
ICdmSource
closeOpenConnections
in interface ICdmSource
public java.util.Map<CdmMetaDataPropertyName,java.lang.String> getMetaDataMap() throws CdmSourceException
getMetaDataMap
in interface ICdmSource
CdmSourceException
public org.springframework.beans.factory.config.BeanDefinition getDatasourceBean()
ICdmDataSource
getDatasourceBean
in interface ICdmDataSource
public org.springframework.beans.factory.config.BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll)
getHibernatePropertiesBean
in interface ICdmDataSource
@Deprecated public org.springframework.beans.factory.config.BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll, java.lang.Boolean showSql, java.lang.Boolean formatSql, java.lang.Boolean registerSearchListener, java.lang.Class<? extends org.hibernate.cache.spi.RegionFactory> cacheProviderClass)
getHibernatePropertiesBean
in interface ICdmDataSource
public org.springframework.beans.factory.config.BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll, HibernateConfiguration hibernateConfig)
getHibernatePropertiesBean
in interface ICdmDataSource
hbm2dll
- schema validationhibernateConfig
- the hibernate configurationbean definition
public java.lang.String getFilePath()
getFilePath
in interface ICdmDataSource
public H2Mode getMode()
getMode
in interface ICdmDataSource
public java.lang.String getUsername()
getUsername
in interface ICdmDataSource
public java.lang.String getPassword()
getPassword
in interface ICdmDataSource
public java.lang.String getDatabase()
getDatabase
in interface ICdmDataSource
public void setMode(H2Mode h2Mode)
setMode
in interface ICdmDataSource
public void setUsername(java.lang.String username)
setUsername
in interface ICdmDataSource
public void setPassword(java.lang.String password)
setPassword
in interface ICdmDataSource
public void setDatabase(java.lang.String database)
setDatabase
in interface ICdmDataSource
public DatabaseTypeEnum getDatabaseType()
ICdmDataSource
getDatabaseType
in interface ICdmDataSource
null
if the bean or the driver class property does not exist or the driver class is unknown.public boolean testConnection() throws java.lang.ClassNotFoundException, java.sql.SQLException
ICdmDataSource
testConnection
in interface ICdmDataSource
java.lang.ClassNotFoundException
java.sql.SQLException
public java.sql.ResultSet executeQuery(java.lang.String query) throws java.sql.SQLException
ICdmDataSource
executeQuery
in interface ICdmDataSource
java.sql.SQLException
public int executeUpdate(java.lang.String sqlUpdate) throws java.sql.SQLException
ICdmDataSource
executeUpdate
in interface ICdmDataSource
java.sql.SQLException
public void startTransaction()
ICdmDataSource
startTransaction
in interface ICdmDataSource
public void commitTransaction() throws java.sql.SQLException
ICdmDataSource
commitTransaction
in interface ICdmDataSource
java.sql.SQLException
public void rollback() throws java.sql.SQLException
ICdmDataSource
rollback
in interface ICdmDataSource
java.sql.SQLException
public java.lang.Object getSingleValue(java.lang.String query) throws java.sql.SQLException
ICdmDataSource
null
is returned.
Caution This method opens a connection on first use. Subsequent calls will use the same connection.
Please close the connection when not needed anymore with ICdmSource.closeOpenConnections()
getSingleValue
in interface ICdmDataSource
java.sql.SQLException
public java.sql.DatabaseMetaData getMetaData()
ICdmDataSource
DatabaseMetaData
for this
datasource.
ICdmSource.closeOpenConnections()
getMetaData
in interface ICdmDataSource
Copyright © 2007-2020 EDIT. All Rights Reserved.