use of org.apache.tomcat.dbcp.dbcp2.PoolableCallableStatement in project datanucleus-rdbms by datanucleus.
the class PooledConnectionImpl method makeObject.
/**
* My {@link KeyedPooledObjectFactory} method for creating {@link PreparedStatement}s.
*
* @param key
* The key for the {@link PreparedStatement} to be created.
*/
@SuppressWarnings("resource")
@Override
public PooledObject<DelegatingPreparedStatement> makeObject(final PStmtKey key) throws Exception {
if (null == key) {
throw new IllegalArgumentException("Prepared statement key is null or invalid.");
}
if (key.getStmtType() == StatementType.PREPARED_STATEMENT) {
final PreparedStatement statement = (PreparedStatement) key.createStatement(connection);
// Unable to find way to avoid this
@SuppressWarnings({ "rawtypes", "unchecked" }) final PoolablePreparedStatement pps = new PoolablePreparedStatement(statement, key, pStmtPool, delegatingConnection);
return new DefaultPooledObject<>(pps);
}
final CallableStatement statement = (CallableStatement) key.createStatement(connection);
@SuppressWarnings("unchecked") final PoolableCallableStatement pcs = new PoolableCallableStatement(statement, key, pStmtPool, (DelegatingConnection<Connection>) delegatingConnection);
return new DefaultPooledObject<>(pcs);
}
use of org.apache.tomcat.dbcp.dbcp2.PoolableCallableStatement in project tomcat by apache.
the class PooledConnectionImpl method makeObject.
/**
* My {@link KeyedPooledObjectFactory} method for creating {@link PreparedStatement}s.
*
* @param key
* The key for the {@link PreparedStatement} to be created.
*/
@Override
public PooledObject<DelegatingPreparedStatement> makeObject(final PStmtKey key) throws Exception {
if (null == key) {
throw new IllegalArgumentException("Prepared statement key is null or invalid.");
}
if (key.getStmtType() == StatementType.PREPARED_STATEMENT) {
final PreparedStatement statement = (PreparedStatement) key.createStatement(connection);
// Unable to find way to avoid this
@SuppressWarnings({ "rawtypes", "unchecked" }) final PoolablePreparedStatement pps = new PoolablePreparedStatement(statement, key, pStmtPool, delegatingConnection);
return new DefaultPooledObject<>(pps);
}
final CallableStatement statement = (CallableStatement) key.createStatement(connection);
@SuppressWarnings("unchecked") final PoolableCallableStatement pcs = new PoolableCallableStatement(statement, key, pStmtPool, (DelegatingConnection<Connection>) delegatingConnection);
return new DefaultPooledObject<>(pcs);
}
Aggregations