public class DataSourceImpl extends java.lang.Object implements HybrisDataSource
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.Integer |
OBJ_POOL_V1_WHEN_EXHAUSTED_BLOCK |
protected static java.lang.Integer |
OBJ_POOL_V1_WHEN_EXHAUSTED_FAIL |
protected static java.lang.Integer |
OBJ_POOL_V1_WHEN_EXHAUSTED_GROW |
| Modifier | Constructor and Description |
|---|---|
|
DataSourceImpl(Tenant tenant,
java.lang.String id,
java.util.Map<java.lang.String,java.lang.String> params,
boolean readOnly,
DataSourceFactory factory)
Creates a new data source using connection parameters.
|
protected |
DataSourceImpl(Tenant tenant,
java.lang.String id,
java.util.Map<java.lang.String,java.lang.String> params,
java.lang.String jndiName,
boolean readOnly,
DataSourceFactory factory) |
|
DataSourceImpl(Tenant tenant,
java.lang.String id,
java.lang.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.
since ages - 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 java.sql.Connection |
doGetConnection(boolean transactionBound) |
java.sql.Connection |
getConnection()
Fetches a new connection from connection pool.
|
java.sql.Connection |
getConnection(boolean transactionBound)
Fetches a new connection from connection pool.
|
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password) |
java.util.Map<java.lang.String,java.lang.String> |
getConnectionParameters() |
JDBCConnectionPool |
getConnectionPool() |
java.lang.String |
getCustomSessionSQL() |
java.lang.String |
getDatabaseName() |
java.lang.String |
getDatabaseURL() |
java.lang.String |
getDatabaseUser() |
java.lang.String |
getDatabaseVersion() |
DataSourceFactory |
getDataSourceFactory() |
java.lang.String |
getDriverVersion() |
java.lang.String |
getID() |
JDBCInterceptor |
getJDBCInterceptor() |
java.lang.String |
getJNDIName() |
int |
getLoginTimeout() |
JDBCLogUtils |
getLogUtils() |
java.io.PrintWriter |
getLogWriter() |
int |
getMaxAllowedPhysicalOpen() |
int |
getMaxInUse() |
int |
getMaxPhysicalOpen() |
int |
getMaxPreparedParameterCount() |
long |
getMillisWaitedForConnection() |
int |
getNumInUse() |
int |
getNumPhysicalOpen() |
java.util.logging.Logger |
getParentLogger() |
java.lang.String |
getSchemaName()
Tries to get the used schema name for a given SQLserver or oracle connection.
|
java.lang.String |
getTablePrefix() |
Tenant |
getTenant() |
static java.lang.String |
getUserNameFromDatabaseMetaData(java.sql.DatabaseMetaData dmd,
java.lang.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(java.lang.Class<?> arg0) |
protected java.lang.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(java.io.PrintWriter arg0) |
java.lang.String |
toString() |
long |
totalGets() |
DataAccessException |
translateToDataAccessException(java.sql.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(java.lang.Class<T> arg0) |
protected static final java.lang.Integer OBJ_POOL_V1_WHEN_EXHAUSTED_FAIL
protected static final java.lang.Integer OBJ_POOL_V1_WHEN_EXHAUSTED_BLOCK
protected static final java.lang.Integer OBJ_POOL_V1_WHEN_EXHAUSTED_GROW
public DataSourceImpl(Tenant tenant, java.lang.String id, java.util.Map<java.lang.String,java.lang.String> params, boolean readOnly, DataSourceFactory factory)
tenant - the owning tenantparams - the connection parameterspublic DataSourceImpl(Tenant tenant, java.lang.String id, java.lang.String jndiName, boolean readOnly, DataSourceFactory factory)
tenant - the owning tenantjndiName - the JNDI name of the actual data sourceprotected DataSourceImpl(Tenant tenant, java.lang.String id, java.util.Map<java.lang.String,java.lang.String> params, java.lang.String jndiName, boolean readOnly, DataSourceFactory factory)
public java.lang.String getDriverVersion()
getDriverVersion in interface HybrisDataSourceprotected boolean determineBlockingFromV1Property(int whenExhaustedAction)
@Deprecated protected GenericObjectPool.Config createPoolConfig()
createNewPoolConfig() to create GenericObjectPoolConfig instead.protected GenericObjectPoolConfig createNewPoolConfig()
public java.util.Map<java.lang.String,java.lang.String> getConnectionParameters()
getConnectionParameters in interface HybrisDataSourcepublic java.lang.String getJNDIName()
getJNDIName in interface HybrisDataSourcepublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getID()
getID in interface HybrisDataSourcepublic JDBCConnectionPool getConnectionPool()
getConnectionPool in interface HybrisDataSourcepublic Tenant getTenant()
getTenant in interface HybrisDataSourcepublic java.sql.Connection getConnection()
throws java.sql.SQLException
Transaction is currently running the connection is
transaction bound (the connection which BEGIN and COMMIT/ROLLBACK is called upon).getConnection in interface javax.sql.DataSourcejava.sql.SQLExceptionpublic java.sql.Connection getConnection(boolean transactionBound)
throws java.sql.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 returnedjava.sql.SQLExceptionprotected java.sql.Connection doGetConnection(boolean transactionBound)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.sql.Connection getConnection(java.lang.String username,
java.lang.String password)
throws java.sql.SQLException
getConnection in interface javax.sql.DataSourcejava.sql.SQLExceptionpublic 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 java.lang.String getDatabaseName()
getDatabaseName in interface HybrisDataSourcepublic int getMaxPreparedParameterCount()
getMaxPreparedParameterCount in interface HybrisDataSourcepublic static java.lang.String getUserNameFromDatabaseMetaData(java.sql.DatabaseMetaData dmd,
java.lang.String fallback)
public java.lang.String getDatabaseVersion()
getDatabaseVersion in interface HybrisDataSourcepublic java.lang.String getDatabaseURL()
getDatabaseURL in interface HybrisDataSourcepublic java.lang.String getCustomSessionSQL()
getCustomSessionSQL in interface HybrisDataSourcepublic java.lang.String getDatabaseUser()
getDatabaseUser in interface HybrisDataSourcepublic java.lang.String getSchemaName()
getSchemaName in interface HybrisDataSourceprotected java.lang.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 java.lang.String getTablePrefix()
getTablePrefix in interface HybrisDataSourcepublic java.io.PrintWriter getLogWriter()
throws java.sql.SQLException
getLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic void setLogWriter(java.io.PrintWriter arg0)
throws java.sql.SQLException
setLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic int getLoginTimeout()
throws java.sql.SQLException
getLoginTimeout in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic void setLoginTimeout(int arg0)
throws java.sql.SQLException
setLoginTimeout in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic boolean isWrapperFor(java.lang.Class<?> arg0)
throws java.sql.SQLException
isWrapperFor in interface java.sql.Wrapperjava.sql.SQLExceptionpublic <T> T unwrap(java.lang.Class<T> arg0)
throws java.sql.SQLException
unwrap in interface java.sql.Wrapperjava.sql.SQLExceptionpublic java.util.logging.Logger getParentLogger()
throws java.sql.SQLFeatureNotSupportedException
getParentLogger in interface javax.sql.CommonDataSourcejava.sql.SQLFeatureNotSupportedExceptionpublic DataAccessException translateToDataAccessException(java.sql.SQLException e)
HybrisDataSourceDataAccessException exactly like it would have been done when using Spring JdbcTemplate.translateToDataAccessException in interface HybrisDataSourcepublic JDBCInterceptor getJDBCInterceptor()
getJDBCInterceptor in interface HybrisDataSourceCopyright © 2018 SAP SE. All Rights Reserved.