public class DataSourceImpl extends Object implements HybrisDataSource
| Modifier and Type | Field and Description |
|---|---|
protected static Integer |
OBJ_POOL_V1_WHEN_EXHAUSTED_BLOCK |
protected static Integer |
OBJ_POOL_V1_WHEN_EXHAUSTED_FAIL |
protected static Integer |
OBJ_POOL_V1_WHEN_EXHAUSTED_GROW |
| Modifier | Constructor and Description |
|---|---|
|
DataSourceImpl(Tenant tenant,
String id,
Map<String,String> params,
boolean readOnly,
DataSourceFactory factory)
Creates a new data source using connection parameters.
|
protected |
DataSourceImpl(Tenant tenant,
String id,
Map<String,String> params,
String jndiName,
boolean readOnly,
DataSourceFactory factory) |
|
DataSourceImpl(Tenant tenant,
String id,
String jndiName,
boolean readOnly,
DataSourceFactory factory)
Creates a new data source using a existing JNDI data source.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
cannotConnect() |
protected GenericObjectPoolConfig |
createNewPoolConfig() |
protected GenericObjectPool.Config |
createPoolConfig()
Deprecated.
Database connection pool now uses version 2 of Apache Commons Pool, so please use
createNewPoolConfig() to create GenericObjectPoolConfig instead. |
void |
destroy() |
protected boolean |
determineBlockingFromV1Property(int whenExhaustedAction) |
protected Connection |
doGetConnection(boolean transactionBound) |
Connection |
getConnection()
Fetches a new connection from connection pool.
|
Connection |
getConnection(boolean transactionBound)
Fetches a new connection from connection pool.
|
Connection |
getConnection(String username,
String password) |
Map<String,String> |
getConnectionParameters() |
JDBCConnectionPool |
getConnectionPool() |
String |
getCustomSessionSQL() |
String |
getDatabaseName() |
String |
getDatabaseURL() |
String |
getDatabaseUser() |
String |
getDatabaseVersion() |
DataSourceFactory |
getDataSourceFactory() |
String |
getDriverVersion() |
String |
getID() |
String |
getJNDIName() |
int |
getLoginTimeout() |
JDBCLogUtils |
getLogUtils() |
PrintWriter |
getLogWriter() |
int |
getMaxAllowedPhysicalOpen() |
int |
getMaxInUse() |
int |
getMaxPhysicalOpen() |
int |
getMaxPreparedParameterCount() |
long |
getMillisWaitedForConnection() |
int |
getNumInUse() |
int |
getNumPhysicalOpen() |
Logger |
getParentLogger() |
String |
getSchemaName()
Tries to get the used schema name for a given SQLserver or oracle connection.
|
String |
getTablePrefix() |
Tenant |
getTenant() |
static String |
getUserNameFromDatabaseMetaData(DatabaseMetaData dmd,
String fallback) |
void |
invalidate(ConnectionImpl conn) |
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.
|
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.
|
boolean |
isReadOnly() |
boolean |
isWrapperFor(Class<?> arg0) |
protected String |
readSchemaName() |
void |
resetStats()
Reset the statistics.
|
void |
returnToPool(ConnectionImpl conn) |
void |
setDBLog(boolean active)
set the value of the project.properties setting 'db.log.active'
|
void |
setDBLogAppendStackTrace(boolean active)
set the value of the project.properties setting 'db.log.appendStackTrace'
|
void |
setLoginTimeout(int arg0) |
void |
setLogWriter(PrintWriter arg0) |
String |
toString() |
long |
totalGets() |
DataAccessException |
translateToDataAccessException(SQLException e)
Translates the given raw SQL exception into a Spring
DataAccessException exactly like it would have been done when using Spring JdbcTemplate. |
<T> T |
unwrap(Class<T> arg0) |
protected static final Integer OBJ_POOL_V1_WHEN_EXHAUSTED_FAIL
protected static final Integer OBJ_POOL_V1_WHEN_EXHAUSTED_BLOCK
protected static final Integer OBJ_POOL_V1_WHEN_EXHAUSTED_GROW
public DataSourceImpl(Tenant tenant, String id, Map<String,String> params, boolean readOnly, DataSourceFactory factory)
tenant - the owning tenantparams - the connection parameterspublic DataSourceImpl(Tenant tenant, String id, String jndiName, boolean readOnly, DataSourceFactory factory)
tenant - the owning tenantjndiName - the JNDI name of the actual data sourcepublic String getDriverVersion()
getDriverVersion in interface HybrisDataSourceprotected boolean determineBlockingFromV1Property(int whenExhaustedAction)
@Deprecated protected GenericObjectPool.Config createPoolConfig()
createNewPoolConfig() to create GenericObjectPoolConfig instead.protected GenericObjectPoolConfig createNewPoolConfig()
public Map<String,String> getConnectionParameters()
getConnectionParameters in interface HybrisDataSourcepublic String getJNDIName()
getJNDIName in interface HybrisDataSourcepublic String getID()
getID in interface HybrisDataSourcepublic JDBCConnectionPool getConnectionPool()
getConnectionPool in interface HybrisDataSourcepublic Tenant getTenant()
getTenant in interface HybrisDataSourcepublic Connection getConnection() throws SQLException
Transaction is currently running the connection is
transaction bound (the connection which BEGIN and COMMIT/ROLLBACK is called upon).getConnection in interface DataSourceSQLExceptionpublic Connection getConnection(boolean transactionBound) throws SQLException
Transaction is currently running the connection is
either transaction bound (the connection which BEGIN and COMMIT/ROLLBACK is called upon) or a 'fresh' one.getConnection in interface HybrisDataSourcetransactionBound - only valid if transaction is currently running: if true connection is transaction bound, if false a
'fresh' one is returnedSQLExceptionprotected Connection doGetConnection(boolean transactionBound) throws SQLException
SQLExceptionpublic Connection getConnection(String username, String password) throws SQLException
getConnection in interface DataSourceSQLExceptionpublic void returnToPool(ConnectionImpl conn)
returnToPool in interface HybrisDataSourcepublic void invalidate(ConnectionImpl conn)
invalidate in interface HybrisDataSourcepublic void destroy()
destroy in interface HybrisDataSourcepublic int getNumInUse()
getNumInUse in interface HybrisDataSourcepublic int getNumPhysicalOpen()
getNumPhysicalOpen in interface HybrisDataSourcepublic int getMaxInUse()
getMaxInUse in interface HybrisDataSourcepublic int getMaxPhysicalOpen()
getMaxPhysicalOpen in interface HybrisDataSourcepublic long totalGets()
totalGets in interface HybrisDataSourceHybrisDataSource.resetStats()public int getMaxAllowedPhysicalOpen()
getMaxAllowedPhysicalOpen in interface HybrisDataSourcepublic long getMillisWaitedForConnection()
getMillisWaitedForConnection in interface HybrisDataSourcepublic void resetStats()
HybrisDataSourceHybrisDataSource.getMillisWaitedForConnection(), HybrisDataSource.getMaxInUse() and
HybrisDataSource.totalGets()resetStats in interface HybrisDataSourcepublic JDBCLogUtils getLogUtils()
getLogUtils in interface HybrisDataSourcepublic String getDatabaseName()
getDatabaseName in interface HybrisDataSourcepublic int getMaxPreparedParameterCount()
getMaxPreparedParameterCount in interface HybrisDataSourcepublic static String getUserNameFromDatabaseMetaData(DatabaseMetaData dmd, String fallback)
public String getDatabaseVersion()
getDatabaseVersion in interface HybrisDataSourcepublic String getDatabaseURL()
getDatabaseURL in interface HybrisDataSourcepublic String getCustomSessionSQL()
getCustomSessionSQL in interface HybrisDataSourcepublic String getDatabaseUser()
getDatabaseUser in interface HybrisDataSourcepublic String getSchemaName()
getSchemaName in interface HybrisDataSourceprotected String readSchemaName()
public boolean cannotConnect()
cannotConnect in interface HybrisDataSourcetrue if a connection the pool is not possible.public DataSourceFactory getDataSourceFactory()
getDataSourceFactory in interface HybrisDataSourcepublic boolean isDBLogActive()
isDBLogActive in interface HybrisDataSourcepublic boolean isDBLogAppendStackTraceActive()
isDBLogAppendStackTraceActive in interface HybrisDataSourcepublic void setDBLog(boolean active)
setDBLog in interface HybrisDataSourcepublic void setDBLogAppendStackTrace(boolean active)
setDBLogAppendStackTrace in interface HybrisDataSourcepublic boolean isReadOnly()
isReadOnly in interface HybrisDataSourcetrue if the datasoure is read-onlypublic String getTablePrefix()
getTablePrefix in interface HybrisDataSourcepublic PrintWriter getLogWriter() throws SQLException
getLogWriter in interface CommonDataSourceSQLExceptionpublic void setLogWriter(PrintWriter arg0) throws SQLException
setLogWriter in interface CommonDataSourceSQLExceptionpublic int getLoginTimeout()
throws SQLException
getLoginTimeout in interface CommonDataSourceSQLExceptionpublic void setLoginTimeout(int arg0)
throws SQLException
setLoginTimeout in interface CommonDataSourceSQLExceptionpublic boolean isWrapperFor(Class<?> arg0) throws SQLException
isWrapperFor in interface WrapperSQLExceptionpublic <T> T unwrap(Class<T> arg0) throws SQLException
unwrap in interface WrapperSQLExceptionpublic Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger in interface CommonDataSourceSQLFeatureNotSupportedExceptionpublic DataAccessException translateToDataAccessException(SQLException e)
HybrisDataSourceDataAccessException exactly like it would have been done when using Spring JdbcTemplate.translateToDataAccessException in interface HybrisDataSourceCopyright © 2017 SAP SE. All Rights Reserved.