| Method from org.apache.commons.dbcp.PoolingDriver Detail: |
public boolean acceptsURL(String url) throws SQLException {
try {
return url.startsWith(URL_PREFIX);
} catch(NullPointerException e) {
return false;
}
}
|
public synchronized void closePool(String name) throws SQLException {
ObjectPool pool = (ObjectPool) _pools.get(name);
if (pool != null) {
_pools.remove(name);
try {
pool.close();
}
catch (Exception e) {
throw new SQLNestedException("Error closing pool " + name, e);
}
}
}
|
public Connection connect(String url,
Properties info) throws SQLException {
if(acceptsURL(url)) {
ObjectPool pool = getConnectionPool(url.substring(URL_PREFIX_LEN));
if(null == pool) {
throw new SQLException("No pool found for " + url + ".");
} else {
try {
Connection conn = (Connection)(pool.borrowObject());
if (conn != null) {
conn = new PoolGuardConnectionWrapper(pool, conn);
}
return conn;
} catch(SQLException e) {
throw e;
} catch(NoSuchElementException e) {
throw new SQLNestedException("Cannot get a connection, pool error: " + e.getMessage(), e);
} catch(RuntimeException e) {
throw e;
} catch(Exception e) {
throw new SQLNestedException("Cannot get a connection, general error: " + e.getMessage(), e);
}
}
} else {
return null;
}
}
|
public synchronized ObjectPool getConnectionPool(String name) throws SQLException {
ObjectPool pool = (ObjectPool)(_pools.get(name));
if(null == pool) {
InputStream in = this.getClass().getResourceAsStream(String.valueOf(name) + ".jocl");
if(null != in) {
JOCLContentHandler jocl = null;
try {
jocl = JOCLContentHandler.parse(in);
}
catch (SAXException e) {
throw new SQLNestedException("Could not parse configuration file", e);
}
catch (IOException e) {
throw new SQLNestedException("Could not load configuration file", e);
}
if(jocl.getType(0).equals(String.class)) {
pool = getPool((String)(jocl.getValue(0)));
if(null != pool) {
registerPool(name,pool);
}
} else {
pool = ((PoolableConnectionFactory)(jocl.getValue(0))).getPool();
if(null != pool) {
registerPool(name,pool);
}
}
}
else {
throw new SQLException("Configuration file not found");
}
}
return pool;
}
|
public int getMajorVersion() {
return MAJOR_VERSION;
}
|
public int getMinorVersion() {
return MINOR_VERSION;
}
|
public synchronized ObjectPool getPool(String name) {
try {
return getConnectionPool(name);
}
catch (Exception e) {
throw new DbcpException(e);
}
} Deprecated! This - will be removed in a future version of DBCP.
WARNING: This method throws DbcpExceptions (RuntimeExceptions)
and will be replaced by the protected getConnectionPool method. |
public synchronized String[] getPoolNames() throws SQLException {
Set names = _pools.keySet();
return (String[]) names.toArray(new String[names.size()]);
}
|
public DriverPropertyInfo[] getPropertyInfo(String url,
Properties info) {
return new DriverPropertyInfo[0];
}
|
public void invalidateConnection(Connection conn) throws SQLException {
if (conn instanceof PoolGuardConnectionWrapper) { // normal case
PoolGuardConnectionWrapper pgconn = (PoolGuardConnectionWrapper) conn;
ObjectPool pool = pgconn.pool;
Connection delegate = pgconn.delegate;
try {
pool.invalidateObject(delegate);
}
catch (Exception e) {
}
pgconn.delegate = null;
}
else {
throw new SQLException("Invalid connection class");
}
}
Invalidates the given connection. |
public static synchronized boolean isAccessToUnderlyingConnectionAllowed() {
return accessToUnderlyingConnectionAllowed;
}
Returns the value of the accessToUnderlyingConnectionAllowed property. |
public boolean jdbcCompliant() {
return true;
}
|
public synchronized void registerPool(String name,
ObjectPool pool) {
_pools.put(name,pool);
}
|
public static synchronized void setAccessToUnderlyingConnectionAllowed(boolean allow) {
accessToUnderlyingConnectionAllowed = allow;
}
Sets the value of the accessToUnderlyingConnectionAllowed property.
It controls if the PoolGuard allows access to the underlying connection.
(Default: false) |