2
* Licensed to the Apache Software Foundation (ASF) under one
3
* or more contributor license agreements. See the NOTICE file
4
* distributed with this work for additional information
5
* regarding copyright ownership. The ASF licenses this file
6
* to you under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
19
* $Id: ConnectionPool.java,v 1.2 2009/12/10 03:18:45 matthewoliver Exp $
22
package org.apache.xalan.lib.sql;
24
import java.sql.Connection;
25
import java.sql.SQLException;
26
import java.util.Properties;
29
* An interface used to build wrapper classes around existing
30
* Connection Pool libraries.
31
* Title: ConnectionPool<p>
32
* @author John Gentilin
35
public interface ConnectionPool
39
* Determine if a Connection Pool has been disabled. If a Connection pool
40
* is disabled, then it will only manage connections that are in use.
43
public boolean isEnabled( );
46
* The Driver and URL are the only required parmeters.
50
public void setDriver( String d );
56
public void setURL( String url );
59
* Start downsizeing the pool, this usally happens right after the
60
* pool has been marked as Inactive and we are removing connections
61
* that are not currently inuse.
64
public void freeUnused( );
68
* Provide an indicator to the PoolManager when the Pool can be removed
69
* from the Pool Table.
72
public boolean hasActiveConnections( );
75
* The rest of the protocol parameters can eiter be passed in as
76
* just Username and Password or as a property collection. If the
77
* property collection is used, then the sperate username and password
78
* may be ignored, it is up to the wrapper implementation to handle
79
* the situation. If the connection information changes while after the
80
* pool has been established, the wrapper implementation should ignore
81
* the change and throw an error.
85
public void setPassword( String p );
91
public void setUser( String u );
95
* Set tne minimum number of connections that are to be maintained in the
100
public void setMinConnections( int n );
103
* Test to see if the connection info is valid to make a real connection
104
* to the database. This method may cause the pool to be crated and filled
105
* with min connections.
108
public boolean testConnection( );
111
* Retrive a database connection from the pool
113
* @throws SQLException
115
public Connection getConnection( )throws SQLException;
118
* Return a connection to the pool, the connection may be closed if the
119
* pool is inactive or has exceeded the max number of free connections
122
* @throws SQLException
124
public void releaseConnection( Connection con )throws SQLException;
127
* Provide a mechinism to return a connection to the pool on Error.
128
* A good default behaviour is to close this connection and build
129
* a new one to replace it. Some JDBC impl's won't allow you to
130
* reuse a connection after an error occurs.
133
* @throws SQLException
135
public void releaseConnectionOnError( Connection con )throws SQLException;
139
* The Pool can be Enabled and Disabled. Disabling the pool
140
* closes all the outstanding Unused connections and any new
141
* connections will be closed upon release.
142
* @param flag Control the Connection Pool. If it is enabled
143
* then Connections will actuall be held around. If disabled
144
* then all unused connections will be instantly closed and as
145
* connections are released they are closed and removed from the pool.
148
public void setPoolEnabled( final boolean flag );
151
* Used to pass in extra configuration options during the
152
* database connect phase.
154
public void setProtocol(Properties p);