Package de.hybris.platform.jdbcwrapper
Class DataSourceImpl
java.lang.Object
de.hybris.platform.jdbcwrapper.DataSourceImpl
- All Implemented Interfaces:
HybrisDataSource,Wrapper,CommonDataSource,DataSource
- Direct Known Subclasses:
SlaveTenantDataSource
DataSource connection factory for JDBC Connections.
CAUTION: Please be aware that this file will be compiled by using jdk 1.6 and jdk 1.7,
for being successful in both cases we have to suppress the generation of the @override annotation. So please DONT OPEN/SAVE this file by using eclipse !!!!
for being successful in both cases we have to suppress the generation of the @override annotation. So please DONT OPEN/SAVE this file by using eclipse !!!!
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionDataSourceImpl(Tenant tenant, String id, String jndiName, boolean readOnly, DataSourceFactory factory) Creates a new data source using a existing JNDI data source.DataSourceImpl(Tenant tenant, String id, Map<String, String> params, boolean readOnly, DataSourceFactory factory) Creates a new data source using connection parameters.protectedDataSourceImpl(Tenant tenant, String id, Map<String, String> params, String jndiName, boolean readOnly, DataSourceFactory factory) -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected org.apache.commons.pool2.impl.GenericObjectPoolConfigprotected org.apache.commons.pool.impl.GenericObjectPool.ConfigDeprecated, for removal: This API element is subject to removal in a future version.voiddestroy()protected booleandetermineBlockingFromV1Property(int whenExhaustedAction) protected ConnectiondoGetConnection(boolean transactionBound) Fetches a new connection from connection pool.getConnection(boolean transactionBound) Fetches a new connection from connection pool.getConnection(String username, String password) getID()intintintintintlongintintintTries to get the used schema name for a given SQLserver or oracle connection.static StringgetUserNameFromDatabaseMetaData(DatabaseMetaData dmd, String fallback) voidinvalidate(ConnectionImpl conn) booleanreturns the value of the project.properties property 'db.log.active', which tells if the logging into the jdbc.log is activated or not.booleanreturns the value of the project.properties setting 'db.log.appendStackTrace', which tells if the logging of stacktraces for each statement into the jdbc.log is activated or not.booleanbooleanisWrapperFor(Class<?> arg0) protected StringvoidReset the statistics.voidreturnToPool(ConnectionImpl conn) voidsetDBLog(boolean active) set the value of the project.properties setting 'db.log.active'voidsetDBLogAppendStackTrace(boolean active) set the value of the project.properties setting 'db.log.appendStackTrace'voidsetLoginTimeout(int arg0) voidsetLogWriter(PrintWriter arg0) toString()longorg.springframework.dao.DataAccessExceptionTranslates the given raw SQL exception into a SpringDataAccessExceptionexactly like it would have been done when using SpringJdbcTemplate.<T> TMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilderMethods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
Field Details
-
OBJ_POOL_V1_WHEN_EXHAUSTED_FAIL
-
OBJ_POOL_V1_WHEN_EXHAUSTED_BLOCK
-
OBJ_POOL_V1_WHEN_EXHAUSTED_GROW
-
-
Constructor Details
-
DataSourceImpl
public DataSourceImpl(Tenant tenant, String id, Map<String, String> params, boolean readOnly, DataSourceFactory factory) Creates a new data source using connection parameters.- Parameters:
tenant- the owning tenantparams- the connection parameters
-
DataSourceImpl
public DataSourceImpl(Tenant tenant, String id, String jndiName, boolean readOnly, DataSourceFactory factory) Creates a new data source using a existing JNDI data source.- Parameters:
tenant- the owning tenantjndiName- the JNDI name of the actual data source
-
DataSourceImpl
-
-
Method Details
-
getDriverVersion
- Specified by:
getDriverVersionin interfaceHybrisDataSource- Returns:
- the driverVersion
-
determineBlockingFromV1Property
protected boolean determineBlockingFromV1Property(int whenExhaustedAction) -
createPoolConfig
@Deprecated(since="ages", forRemoval=true) protected org.apache.commons.pool.impl.GenericObjectPool.Config createPoolConfig()Deprecated, for removal: This API element is subject to removal in a future version.since ages - Database connection pool now uses version 2 of Apache Commons Pool, so please usecreateNewPoolConfig()to create GenericObjectPoolConfig instead. -
createNewPoolConfig
protected org.apache.commons.pool2.impl.GenericObjectPoolConfig createNewPoolConfig() -
getConnectionParameters
- Specified by:
getConnectionParametersin interfaceHybrisDataSource
-
getJNDIName
- Specified by:
getJNDINamein interfaceHybrisDataSource- Returns:
- the JNDI name
-
toString
-
getID
- Specified by:
getIDin interfaceHybrisDataSource- Returns:
- the ID of the current data source
-
getConnectionPool
- Specified by:
getConnectionPoolin interfaceHybrisDataSource
-
getTenant
- Specified by:
getTenantin interfaceHybrisDataSource
-
getConnection
Fetches a new connection from connection pool. If aTransactionis currently running the connection is transaction bound (the connection which BEGIN and COMMIT/ROLLBACK is called upon).- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getConnection
Fetches a new connection from connection pool. If aTransactionis currently running the connection is either transaction bound (the connection which BEGIN and COMMIT/ROLLBACK is called upon) or a 'fresh' one.- Specified by:
getConnectionin interfaceHybrisDataSource- Parameters:
transactionBound- only valid if transaction is currently running: if true connection is transaction bound, if false a 'fresh' one is returned- Throws:
SQLException
-
doGetConnection
- Throws:
SQLException
-
getConnection
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
returnToPool
- Specified by:
returnToPoolin interfaceHybrisDataSource
-
invalidate
- Specified by:
invalidatein interfaceHybrisDataSource
-
destroy
public void destroy()- Specified by:
destroyin interfaceHybrisDataSource
-
getNumInUse
public int getNumInUse()- Specified by:
getNumInUsein interfaceHybrisDataSource- Returns:
- the number of instances currently borrowed from the pool.
-
getNumPhysicalOpen
public int getNumPhysicalOpen()- Specified by:
getNumPhysicalOpenin interfaceHybrisDataSource- Returns:
- number of currently open JDBC connections.
-
getNumReadOnlyOpen
public int getNumReadOnlyOpen()- Specified by:
getNumReadOnlyOpenin interfaceHybrisDataSource- Returns:
- number of open connections that are read-only
-
getMaxInUse
public int getMaxInUse()- Specified by:
getMaxInUsein interfaceHybrisDataSource- Returns:
- the maximum number of the 'in use' connection
-
getMaxPhysicalOpen
public int getMaxPhysicalOpen()- Specified by:
getMaxPhysicalOpenin interfaceHybrisDataSource- Returns:
- the maximum number of physical SQL connections.
-
totalGets
public long totalGets()- Specified by:
totalGetsin interfaceHybrisDataSource- Returns:
- Total number of connections so far. Reset with
HybrisDataSource.resetStats()
-
getMaxAllowedPhysicalOpen
public int getMaxAllowedPhysicalOpen()- Specified by:
getMaxAllowedPhysicalOpenin interfaceHybrisDataSource- Returns:
- the maximum number of objects that can be allocated by the pool
-
getMillisWaitedForConnection
public long getMillisWaitedForConnection()- Specified by:
getMillisWaitedForConnectionin interfaceHybrisDataSource- Returns:
- the time in milliseconds how long it took to get a connection from the pool
-
resetStats
public void resetStats()Description copied from interface:HybrisDataSourceReset the statistics. Those areHybrisDataSource.getMillisWaitedForConnection(),HybrisDataSource.getMaxInUse()andHybrisDataSource.totalGets()- Specified by:
resetStatsin interfaceHybrisDataSource
-
getLogUtils
- Specified by:
getLogUtilsin interfaceHybrisDataSource
-
getDatabaseName
- Specified by:
getDatabaseNamein interfaceHybrisDataSource- Returns:
- the database name
-
getMaxPreparedParameterCount
public int getMaxPreparedParameterCount()- Specified by:
getMaxPreparedParameterCountin interfaceHybrisDataSource- Returns:
- the maximum allowed number of parameters within one prepared statement; -1 if no limit exists
-
getUserNameFromDatabaseMetaData
-
getDatabaseVersion
- Specified by:
getDatabaseVersionin interfaceHybrisDataSource- Returns:
- the databaseVersion
-
getDatabaseURL
- Specified by:
getDatabaseURLin interfaceHybrisDataSource- Returns:
- the URL of the database
-
getCustomSessionSQL
- Specified by:
getCustomSessionSQLin interfaceHybrisDataSource
-
getDatabaseUser
- Specified by:
getDatabaseUserin interfaceHybrisDataSource- Returns:
- the database user
-
getSchemaName
Tries to get the used schema name for a given SQLserver or oracle connection.- Specified by:
getSchemaNamein interfaceHybrisDataSource- Returns:
- the schema name of the database
-
readSchemaName
-
cannotConnect
public boolean cannotConnect()- Specified by:
cannotConnectin interfaceHybrisDataSource- Returns:
trueif a connection the pool is not possible.
-
getDataSourceFactory
- Specified by:
getDataSourceFactoryin interfaceHybrisDataSource
-
isDBLogActive
public boolean isDBLogActive()returns the value of the project.properties property 'db.log.active', which tells if the logging into the jdbc.log is activated or not.- Specified by:
isDBLogActivein interfaceHybrisDataSource
-
isDBLogAppendStackTraceActive
public boolean isDBLogAppendStackTraceActive()returns the value of the project.properties setting 'db.log.appendStackTrace', which tells if the logging of stacktraces for each statement into the jdbc.log is activated or not.- Specified by:
isDBLogAppendStackTraceActivein interfaceHybrisDataSource
-
setDBLog
public void setDBLog(boolean active) set the value of the project.properties setting 'db.log.active'- Specified by:
setDBLogin interfaceHybrisDataSource
-
setDBLogAppendStackTrace
public void setDBLogAppendStackTrace(boolean active) set the value of the project.properties setting 'db.log.appendStackTrace'- Specified by:
setDBLogAppendStackTracein interfaceHybrisDataSource
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnlyin interfaceHybrisDataSource- Returns:
trueif the datasoure is read-only
-
getTablePrefix
- Specified by:
getTablePrefixin interfaceHybrisDataSource- Returns:
- the table prefix for all tables
-
getLogWriter
- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceDataSource- Throws:
SQLException
-
setLogWriter
- Specified by:
setLogWriterin interfaceCommonDataSource- Specified by:
setLogWriterin interfaceDataSource- Throws:
SQLException
-
getLoginTimeout
- Specified by:
getLoginTimeoutin interfaceCommonDataSource- Specified by:
getLoginTimeoutin interfaceDataSource- Throws:
SQLException
-
setLoginTimeout
- Specified by:
setLoginTimeoutin interfaceCommonDataSource- Specified by:
setLoginTimeoutin interfaceDataSource- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
getParentLogger
- Specified by:
getParentLoggerin interfaceCommonDataSource- Throws:
SQLFeatureNotSupportedException- Since:
- jdk 1.7
-
translateToDataAccessException
Description copied from interface:HybrisDataSourceTranslates the given raw SQL exception into a SpringDataAccessExceptionexactly like it would have been done when using SpringJdbcTemplate.- Specified by:
translateToDataAccessExceptionin interfaceHybrisDataSource
-
getJDBCInterceptor
- Specified by:
getJDBCInterceptorin interfaceHybrisDataSource
-
createNewPoolConfig()to create GenericObjectPoolConfig instead.