~vcs-imports/xena/trunk

« back to all changes in this revision

Viewing changes to ext/src/xalan-j_2_7_1/src/org/apache/xalan/lib/sql/ConnectionPool.java

  • Committer: matthewoliver
  • Date: 2009-12-10 03:18:07 UTC
  • Revision ID: vcs-imports@canonical.com-20091210031807-l086qguzdlljtkl9
Merged Xena Testing into Xena Stable for the Xena 5 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
9
 *
 
10
 *     http://www.apache.org/licenses/LICENSE-2.0
 
11
 *
 
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.
 
17
 */
 
18
/*
 
19
 * $Id: ConnectionPool.java,v 1.2 2009/12/10 03:18:45 matthewoliver Exp $
 
20
 */
 
21
 
 
22
package org.apache.xalan.lib.sql;
 
23
 
 
24
import java.sql.Connection;
 
25
import java.sql.SQLException;
 
26
import java.util.Properties;
 
27
 
 
28
/**
 
29
 * An interface used to build wrapper classes around existing
 
30
 * Connection Pool libraries.
 
31
 * Title:     ConnectionPool<p>
 
32
 * @author John Gentilin
 
33
 * @version 1.0
 
34
 */
 
35
public interface ConnectionPool
 
36
{
 
37
 
 
38
  /**
 
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.
 
41
   *
 
42
   */
 
43
  public boolean isEnabled( );
 
44
 
 
45
  /**
 
46
   * The Driver and URL are the only required parmeters.
 
47
   * @param d
 
48
   *
 
49
   */
 
50
  public void setDriver( String d );
 
51
 
 
52
  /**
 
53
   * @param url
 
54
   *
 
55
   */
 
56
  public void setURL( String url );
 
57
 
 
58
  /**
 
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.
 
62
   *
 
63
   */
 
64
  public void freeUnused( );
 
65
 
 
66
 
 
67
  /**
 
68
   * Provide an indicator to the PoolManager when the Pool can be removed
 
69
   * from the Pool Table.
 
70
   *
 
71
   */
 
72
  public boolean hasActiveConnections( );
 
73
 
 
74
  /**
 
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.
 
82
   * @param p
 
83
   *
 
84
   */
 
85
  public void setPassword( String p );
 
86
 
 
87
  /**
 
88
   * @param u
 
89
   *
 
90
   */
 
91
  public void setUser( String u );
 
92
 
 
93
 
 
94
  /**
 
95
   * Set tne minimum number of connections that are to be maintained in the
 
96
   * pool.
 
97
   * @param n
 
98
   *
 
99
   */
 
100
  public void setMinConnections( int n );
 
101
 
 
102
  /**
 
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.
 
106
   *
 
107
   */
 
108
  public boolean testConnection( );
 
109
 
 
110
  /**
 
111
   * Retrive a database connection from the pool
 
112
   *
 
113
   * @throws SQLException
 
114
   */
 
115
  public Connection getConnection( )throws SQLException;
 
116
 
 
117
   /**
 
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
 
120
   * @param con
 
121
   *
 
122
   * @throws SQLException
 
123
   */
 
124
  public void releaseConnection( Connection con )throws SQLException;
 
125
 
 
126
   /**
 
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.
 
131
   * @param con
 
132
   *
 
133
   * @throws SQLException
 
134
   */
 
135
  public void releaseConnectionOnError( Connection con )throws SQLException;
 
136
 
 
137
 
 
138
  /**
 
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.
 
146
   *
 
147
   */
 
148
  public void setPoolEnabled( final boolean flag );
 
149
 
 
150
  /**
 
151
   * Used to pass in extra configuration options during the
 
152
   * database connect phase.
 
153
   */
 
154
  public void setProtocol(Properties p);
 
155
 
 
156
 
 
157
}