public class CdmPersistentDataSource extends CdmSource implements ICdmPersistentSource
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DATASOURCE_BEAN_POSTFIX |
DEFAULT_ENTRY, NULL_PORT, server
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.
|
boolean |
equals(java.lang.Object obj) |
java.sql.ResultSet |
executeQuery(java.lang.String query)
Executes a query and returns the ResultSet.
|
int |
executeUpdate(java.lang.String sqlUpdate)
Executes an update
|
static boolean |
exists(java.lang.String strDataSourceName)
Tests existing of the datsource in the according config file.
|
static java.util.List<CdmPersistentDataSource> |
getAllDataSources()
Returns a list of all datasources stored in the datasource config file
|
java.lang.String |
getBeanName()
Returns the name of bean representing this CDM persistent source
|
java.lang.String |
getCdmSourceProperty(CdmPersistentXMLSource.CdmSourceProperties property) |
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.util.logging.Logger |
getParentLogger() |
java.lang.String |
getPassword() |
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) |
protected org.springframework.beans.factory.support.AbstractBeanDefinition |
makeHibernatePropertiesBean(DatabaseTypeEnum dbType,
DbSchemaValidation hbm2dll,
boolean showSql,
boolean formatSql,
boolean registerAuditing,
boolean registerSearchListener,
java.lang.Class<? extends org.hibernate.cache.spi.RegionFactory> cacheProviderClass) |
static CdmPersistentDataSource |
NewDefaultInstance()
Returns the default CdmDataSource
|
static CdmPersistentDataSource |
NewInstance(java.lang.String dataSourceName)
Returns the CdmDataSource named by strDataSource
|
static CdmPersistentDataSource |
NewLocalHsqlInstance()
Returns the default CdmDataSource
|
static CdmPersistentDataSource |
replace(java.lang.String strDataSourceName,
ICdmDataSource dataSource)
Replace the persisted datasource with another one.
|
void |
rollback()
Rolls the connection back.
|
static CdmPersistentDataSource |
save(ICdmDataSource dataSource) |
static CdmPersistentDataSource |
save(java.lang.String strDataSourceName,
ICdmDataSource dataSource)
Saves a datasource to the datasource config file.
|
void |
setDatabase(java.lang.String database) |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(java.io.PrintWriter out) |
void |
setMode(H2Mode h2Mode) |
void |
setPassword(java.lang.String password) |
void |
setPort(int port)
Sets the CDM Source port
|
void |
setServer(java.lang.String server)
Sets the CDM Source server
|
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.
|
java.lang.String |
toString() |
<T> T |
unwrap(java.lang.Class<T> iface) |
static CdmPersistentDataSource |
update(java.lang.String strDataSourceName,
ICdmDataSource dataSource) |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
checkConnection, closeOpenConnections, getConnectionMessage, getDbSchemaVersion, getMetaDataMap, getName, getPort, getServer, isDbEmpty, setName
public static final java.lang.String DATASOURCE_BEAN_POSTFIX
public static final CdmPersistentDataSource NewDefaultInstance() throws DataSourceNotFoundException
DataSourceNotFoundException
public static final CdmPersistentDataSource NewLocalHsqlInstance() throws DataSourceNotFoundException
DataSourceNotFoundException
public static final CdmPersistentDataSource NewInstance(java.lang.String dataSourceName) throws DataSourceNotFoundException
strDataSource
- DataSourceNotFoundException
public java.lang.String getBeanName()
ICdmPersistentSource
getBeanName
in interface ICdmPersistentSource
public java.lang.String getDatabase()
getDatabase
in interface ICdmDataSource
public void setDatabase(java.lang.String database)
setDatabase
in interface ICdmDataSource
public void setServer(java.lang.String server)
CdmSource
setServer
in interface ICdmSource
setServer
in class CdmSource
public void setPort(int port)
CdmSource
setPort
in interface ICdmSource
setPort
in class CdmSource
public java.lang.String getFilePath()
getFilePath
in interface ICdmDataSource
public H2Mode getMode()
getMode
in interface ICdmDataSource
public void setMode(H2Mode h2Mode)
setMode
in interface ICdmDataSource
public java.lang.String getUsername()
getUsername
in interface ICdmDataSource
public void setUsername(java.lang.String username)
setUsername
in interface ICdmDataSource
public java.lang.String getPassword()
getPassword
in interface ICdmDataSource
public void setPassword(java.lang.String password)
setPassword
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 java.lang.String getCdmSourceProperty(CdmPersistentXMLSource.CdmSourceProperties property)
public org.springframework.beans.factory.config.BeanDefinition getDatasourceBean()
getDatasourceBean
in interface ICdmDataSource
public org.springframework.beans.factory.config.BeanDefinition getHibernatePropertiesBean(DbSchemaValidation hbm2dll)
getHibernatePropertiesBean
in interface ICdmDataSource
hbm2dll
- showSql
- @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 static boolean exists(java.lang.String strDataSourceName)
public static CdmPersistentDataSource update(java.lang.String strDataSourceName, ICdmDataSource dataSource) throws DataSourceNotFoundException, java.lang.IllegalArgumentException
strDataSourceName
- dataSource
- code
- DataSourceNotFoundException
java.lang.IllegalArgumentException
public static CdmPersistentDataSource replace(java.lang.String strDataSourceName, ICdmDataSource dataSource) throws DataSourceNotFoundException, java.lang.IllegalArgumentException
strDataSourceName
- dataSource
- DataSourceNotFoundException
java.lang.IllegalArgumentException
public static CdmPersistentDataSource save(ICdmDataSource dataSource) throws java.lang.IllegalArgumentException
dataSource
- java.lang.IllegalArgumentException
public static CdmPersistentDataSource save(java.lang.String strDataSourceName, ICdmDataSource dataSource) throws java.lang.IllegalArgumentException
strDataSourceName
- dataSource
- java.lang.IllegalArgumentException
public static java.util.List<CdmPersistentDataSource> getAllDataSources()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
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 boolean testConnection() throws java.lang.ClassNotFoundException, java.sql.SQLException
ICdmDataSource
testConnection
in interface ICdmDataSource
java.lang.ClassNotFoundException
java.sql.SQLException
public boolean checkConnection() throws CdmSourceException
ICdmSource
checkConnection
in interface ICdmSource
checkConnection
in class CdmSource
CdmSourceException
- if any underlying errorpublic java.lang.String getConnectionMessage()
ICdmSource
getConnectionMessage
in interface ICdmSource
getConnectionMessage
in class CdmSource
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.lang.String getDbSchemaVersion() throws CdmSourceException
ICdmSource
getDbSchemaVersion
in interface ICdmSource
getDbSchemaVersion
in class CdmSource
CdmSourceException
- if any underlying errorpublic boolean isDbEmpty() throws CdmSourceException
ICdmSource
isDbEmpty
in interface ICdmSource
isDbEmpty
in class CdmSource
CdmSourceException
public java.sql.ResultSet executeQuery(java.lang.String query) throws java.sql.SQLException
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.sql.DatabaseMetaData getMetaData()
ICdmDataSource
DatabaseMetaData
for this
datasource.
ICdmSource.closeOpenConnections()
getMetaData
in interface ICdmDataSource
public void closeOpenConnections()
ICdmSource
closeOpenConnections
in interface ICdmSource
closeOpenConnections
in class CdmSource
public java.util.Map<CdmMetaDataPropertyName,java.lang.String> getMetaDataMap() throws CdmSourceException
getMetaDataMap
in interface ICdmSource
CdmSourceException
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 <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.util.logging.Logger getParentLogger()
getParentLogger
in interface javax.sql.CommonDataSource
protected org.springframework.beans.factory.support.AbstractBeanDefinition makeHibernatePropertiesBean(DatabaseTypeEnum dbType, DbSchemaValidation hbm2dll, boolean showSql, boolean formatSql, boolean registerAuditing, boolean registerSearchListener, java.lang.Class<? extends org.hibernate.cache.spi.RegionFactory> cacheProviderClass)
hbm2dll
- showSql
- formatSql
- registerAuditing
- registerSearchListener
- cacheProviderClass
- Copyright © 2007-2020 EDIT. All Rights Reserved.