~ubuntu-branches/ubuntu/precise/tomcat7/precise-proposed

« back to all changes in this revision

Viewing changes to modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java

  • Committer: Bazaar Package Importer
  • Author(s): tony mancill
  • Date: 2011-07-25 22:58:33 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110725225833-1t773ak3y3g9utm2
Tags: 7.0.19-1
* Team upload.
* New upstream release.
  - Includes fix for CVE-2011-2526 (Closes: #634992)
* Remove patch for CVE-2011-2204 (included upstream).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 * contributor license agreements.  See the NOTICE file distributed with
 
4
 * this work for additional information regarding copyright ownership.
 
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 * (the "License"); you may not use this file except in compliance with
 
7
 * the License.  You may obtain a copy of the License at
 
8
 *
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 *
 
11
 * Unless required by applicable law or agreed to in writing, software
 
12
 * distributed under the License is distributed on an "AS IS" BASIS,
 
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
 * See the License for the specific language governing permissions and
 
15
 * limitations under the License.
 
16
 */
 
17
package org.apache.tomcat.jdbc.pool;
 
18
 
 
19
import java.util.Properties;
 
20
 
 
21
import org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition;
 
22
 
 
23
/**
 
24
 * A list of properties that are configurable for a connection pool.
 
25
 * The {@link DataSource} object also implements this interface so that it can be easily configured through
 
26
 * an IoC container without having to specify a secondary object with a setter method.
 
27
 * @author fhanik
 
28
 *
 
29
 */
 
30
 
 
31
public interface PoolConfiguration {
 
32
 
 
33
    /**
 
34
     * JMX prefix for interceptors that register themselves with JMX
 
35
     */
 
36
    public static final String PKG_PREFIX = "org.apache.tomcat.jdbc.pool.interceptor.";
 
37
 
 
38
    /**
 
39
     * Connections that have been abandoned (timed out) wont get closed and reported up unless the number of connections in use are 
 
40
     * above the percentage defined by abandonWhenPercentageFull. 
 
41
     * The value should be between 0-100. 
 
42
     * The default value is 0, which implies that connections are eligible for 
 
43
     * closure as soon as removeAbandonedTimeout has been reached.
 
44
     * @param percentage a value between 0 and 100 to indicate when connections that have been abandoned/timed out are considered abandoned
 
45
     */
 
46
    public void setAbandonWhenPercentageFull(int percentage);
 
47
 
 
48
    /**
 
49
     * Connections that have been abandoned (timed out) wont get closed and reported up unless the number of connections in use are 
 
50
     * above the percentage defined by abandonWhenPercentageFull. 
 
51
     * The value should be between 0-100. 
 
52
     * The default value is 0, which implies that connections are eligible for 
 
53
     * closure as soon as removeAbandonedTimeout has been reached.
 
54
     * @return percentage - a value between 0 and 100 to indicate when connections that have been abandoned/timed out are considered abandoned
 
55
     */
 
56
    public int getAbandonWhenPercentageFull();
 
57
 
 
58
    /**
 
59
     * Returns true if a fair queue is being used by the connection pool
 
60
     * @return true if a fair waiting queue is being used
 
61
     */
 
62
    public boolean isFairQueue();
 
63
 
 
64
    /**
 
65
     * Set to true if you wish that calls to getConnection 
 
66
     * should be treated fairly in a true FIFO fashion. 
 
67
     * This uses the {@link FairBlockingQueue} implementation for the list of the idle connections. 
 
68
     * The default value is true. 
 
69
     * This flag is required when you want to use asynchronous connection retrieval.
 
70
     * @param fairQueue
 
71
     */
 
72
    public void setFairQueue(boolean fairQueue);
 
73
    
 
74
    /**
 
75
     * Property not used. Access is always allowed.
 
76
     * Access can be achieved by calling unwrap on the pooled connection. see {@link javax.sql.DataSource} interface 
 
77
     * or call getConnection through reflection or cast the object as {@link javax.sql.PooledConnection}
 
78
     * @return true
 
79
     */
 
80
    public boolean isAccessToUnderlyingConnectionAllowed();
 
81
 
 
82
    /**
 
83
     * No-op
 
84
     * @param accessToUnderlyingConnectionAllowed parameter ignored
 
85
     */
 
86
    public void setAccessToUnderlyingConnectionAllowed(boolean accessToUnderlyingConnectionAllowed);
 
87
    
 
88
    /**
 
89
     * The connection properties that will be sent to the JDBC driver when establishing new connections. 
 
90
     * Format of the string is [propertyName=property;] <br/>
 
91
     * NOTE - The "user" and "password" properties will be passed explicitly, so they do not need to be included here. 
 
92
     * The default value is null.
 
93
     */
 
94
    public String getConnectionProperties();
 
95
 
 
96
    /**
 
97
     * The properties that will be passed into {@link java.sql.Driver#connect(String, Properties)} method.
 
98
     * Username and password do not need to be stored here, they will be passed into the properties right before the connection is established.
 
99
     * @param connectionProperties properties - Format of the string is [propertyName=property;]* 
 
100
     * Example: prop1=value1;prop2=value2
 
101
     */
 
102
    public void setConnectionProperties(String connectionProperties);
 
103
    
 
104
    /**
 
105
     * Returns the database properties that are passed into the {@link java.sql.Driver#connect(String, Properties)} method.
 
106
     * @return database properties that are passed into the {@link java.sql.Driver#connect(String, Properties)} method.
 
107
     */
 
108
    public Properties getDbProperties();
 
109
 
 
110
    /**
 
111
     * Overrides the database properties passed into the  {@link java.sql.Driver#connect(String, Properties)} method.
 
112
     * @param dbProperties
 
113
     */
 
114
    public void setDbProperties(Properties dbProperties);
 
115
    
 
116
    /**
 
117
     * The default auto-commit state of connections created by this pool. 
 
118
     * If not set (null), default is JDBC driver default (If set to null then the {@link java.sql.Connection#setAutoCommit(boolean)} method will not be called.)
 
119
     * @return the default auto commit setting, null is Driver default.
 
120
     */
 
121
    public Boolean isDefaultAutoCommit();
 
122
    
 
123
    /**
 
124
     * The default auto-commit state of connections created by this pool. 
 
125
     * If not set (null), default is JDBC driver default (If set to null then the {@link java.sql.Connection#setAutoCommit(boolean)} method will not be called.)
 
126
     * @return the default auto commit setting, null is Driver default.
 
127
     */
 
128
    public Boolean getDefaultAutoCommit();
 
129
    
 
130
    /**
 
131
     * The default auto-commit state of connections created by this pool. 
 
132
     * If not set (null), default is JDBC driver default (If set to null then the {@link java.sql.Connection#setAutoCommit(boolean)} method will not be called.)
 
133
     * @param defaultAutoCommit default auto commit setting, null is Driver default.
 
134
     */
 
135
    public void setDefaultAutoCommit(Boolean defaultAutoCommit);
 
136
 
 
137
    /**
 
138
     * If non null, during connection creation the method {@link java.sql.Connection#setCatalog(String)} will be called with the set value.
 
139
     * @return the default catalog, null if not set and accepting the driver default.
 
140
     */
 
141
    public String getDefaultCatalog();
 
142
    
 
143
    /**
 
144
     * If non null, during connection creation the method {@link java.sql.Connection#setCatalog(String)} will be called with the set value.
 
145
     * @param defaultCatalog null if not set and accepting the driver default.
 
146
     */
 
147
    public void setDefaultCatalog(String defaultCatalog);
 
148
    
 
149
    /**
 
150
     * If non null, during connection creation the method {@link java.sql.Connection#setReadOnly(boolean)} will be called with the set value.
 
151
     * @return null if not set and accepting the driver default otherwise the read only value
 
152
     */
 
153
    public Boolean isDefaultReadOnly();
 
154
 
 
155
    /**
 
156
     * If non null, during connection creation the method {@link java.sql.Connection#setReadOnly(boolean)} will be called with the set value.
 
157
     * @return null if not set and accepting the driver default otherwise the read only value
 
158
     */
 
159
    public Boolean getDefaultReadOnly();
 
160
 
 
161
    /**
 
162
     * If non null, during connection creation the method {@link java.sql.Connection#setReadOnly(boolean)} will be called with the set value.
 
163
     * @param defaultReadOnly null if not set and accepting the driver default.
 
164
     */
 
165
    public void setDefaultReadOnly(Boolean defaultReadOnly);
 
166
 
 
167
    
 
168
    /**
 
169
     * Returns the default transaction isolation level. If set to {@link DataSourceFactory#UNKNOWN_TRANSACTIONISOLATION} the method
 
170
     * {@link java.sql.Connection#setTransactionIsolation(int)} will not be called during connection creation.
 
171
     * @return driver transaction isolation level, or -1 {@link DataSourceFactory#UNKNOWN_TRANSACTIONISOLATION} if not set.
 
172
     */
 
173
    public int getDefaultTransactionIsolation();
 
174
    
 
175
    /**
 
176
     * If set to {@link DataSourceFactory#UNKNOWN_TRANSACTIONISOLATION} the method
 
177
     * {@link java.sql.Connection#setTransactionIsolation(int)} will not be called during connection creation. Otherwise the method 
 
178
     * will be called with the isolation level set by this property.
 
179
     * @param defaultTransactionIsolation a value of {@link java.sql.Connection#TRANSACTION_NONE}, {@link java.sql.Connection#TRANSACTION_READ_COMMITTED},
 
180
     * {@link java.sql.Connection#TRANSACTION_READ_UNCOMMITTED}, {@link java.sql.Connection#TRANSACTION_REPEATABLE_READ}, 
 
181
     * {@link java.sql.Connection#TRANSACTION_SERIALIZABLE} or {@link DataSourceFactory#UNKNOWN_TRANSACTIONISOLATION}
 
182
     * The last value will not be set on the connection.
 
183
     */
 
184
    public void setDefaultTransactionIsolation(int defaultTransactionIsolation);
 
185
 
 
186
    /**
 
187
     * The fully qualified Java class name of the JDBC driver to be used. The driver has to be accessible from the same classloader as tomcat-jdbc.jar
 
188
     * @return fully qualified JDBC driver name. 
 
189
     */
 
190
    public String getDriverClassName();
 
191
    
 
192
    /**
 
193
     * The fully qualified Java class name of the JDBC driver to be used. The driver has to be accessible from the same classloader as tomcat-jdbc.jar
 
194
     * @param driverClassName a fully qualified Java class name of a {@link java.sql.Driver} implementation.
 
195
     */
 
196
    public void setDriverClassName(String driverClassName);
 
197
    
 
198
    /**
 
199
     * Returns the number of connections that will be established when the connection pool is started.
 
200
     * Default value is 10 
 
201
     * @return number of connections to be started when pool is started
 
202
     */
 
203
    public int getInitialSize();
 
204
    
 
205
    /**
 
206
     * Set the number of connections that will be established when the connection pool is started.
 
207
     * Default value is 10.
 
208
     * If this value exceeds {@link #setMaxActive(int)} it will automatically be lowered. 
 
209
     * @param initialSize the number of connections to be established.
 
210
     * 
 
211
     */
 
212
    public void setInitialSize(int initialSize);
 
213
 
 
214
    /**
 
215
     * boolean flag to set if stack traces should be logged for application code which abandoned a Connection. 
 
216
     * Logging of abandoned Connections adds overhead for every Connection borrow because a stack trace has to be generated. 
 
217
     * The default value is false.
 
218
     * @return true if the connection pool logs stack traces when connections are borrowed from the pool.
 
219
     */
 
220
    public boolean isLogAbandoned();
 
221
    
 
222
    /**
 
223
     * boolean flag to set if stack traces should be logged for application code which abandoned a Connection. 
 
224
     * Logging of abandoned Connections adds overhead for every Connection borrow because a stack trace has to be generated. 
 
225
     * The default value is false.
 
226
     * @param logAbandoned set to true if stack traces should be recorded when {@link DataSource#getConnection()} is called.
 
227
     */
 
228
    public void setLogAbandoned(boolean logAbandoned);
 
229
 
 
230
    /**
 
231
     * The maximum number of active connections that can be allocated from this pool at the same time. The default value is 100
 
232
     * @return the maximum number of connections used by this pool
 
233
     */
 
234
    public int getMaxActive();
 
235
    
 
236
    /**
 
237
     * The maximum number of active connections that can be allocated from this pool at the same time. The default value is 100
 
238
     * @param maxActive hard limit for number of managed connections by this pool
 
239
     */
 
240
    public void setMaxActive(int maxActive);
 
241
 
 
242
    
 
243
    /**
 
244
     * The maximum number of connections that should be kept in the idle pool if {@link #isPoolSweeperEnabled()} returns false.
 
245
     * If the If {@link #isPoolSweeperEnabled()} returns true, then the idle pool can grow up to {@link #getMaxActive}
 
246
     * and will be shrunk according to {@link #getMinEvictableIdleTimeMillis()} setting.
 
247
     * Default value is maxActive:100  
 
248
     * @return the maximum number of idle connections.
 
249
     */
 
250
    public int getMaxIdle();
 
251
    
 
252
    /**
 
253
     * The maximum number of connections that should be kept in the idle pool if {@link #isPoolSweeperEnabled()} returns false.
 
254
     * If the If {@link #isPoolSweeperEnabled()} returns true, then the idle pool can grow up to {@link #getMaxActive}
 
255
     * and will be shrunk according to {@link #getMinEvictableIdleTimeMillis()} setting.
 
256
     * Default value is maxActive:100  
 
257
     * @param maxIdle the maximum size of the idle pool
 
258
     */
 
259
    public void setMaxIdle(int maxIdle);
 
260
 
 
261
    /**
 
262
     * The maximum number of milliseconds that the pool will wait (when there are no available connections and the 
 
263
     * {@link #getMaxActive} has been reached) for a connection to be returned 
 
264
     * before throwing an exception. Default value is 30000 (30 seconds)
 
265
     * @return the number of milliseconds to wait for a connection to become available if the pool is maxed out.
 
266
     */
 
267
    public int getMaxWait();
 
268
 
 
269
    /**
 
270
     * The maximum number of milliseconds that the pool will wait (when there are no available connections and the 
 
271
     * {@link #getMaxActive} has been reached) for a connection to be returned 
 
272
     * before throwing an exception. Default value is 30000 (30 seconds)
 
273
     * @param maxWait the maximum number of milliseconds to wait.
 
274
     */
 
275
    public void setMaxWait(int maxWait);
 
276
 
 
277
    /**
 
278
     * The minimum amount of time an object must sit idle in the pool before it is eligible for eviction. 
 
279
     * The default value is 60000 (60 seconds).
 
280
     * @return the minimum amount of idle time in milliseconds before a connection is considered idle and eligible for eviction. 
 
281
     */
 
282
    public int getMinEvictableIdleTimeMillis();
 
283
    
 
284
    /**
 
285
     * The minimum amount of time an object must sit idle in the pool before it is eligible for eviction. 
 
286
     * The default value is 60000 (60 seconds).
 
287
     * @param minEvictableIdleTimeMillis the number of milliseconds a connection must be idle to be eligible for eviction.
 
288
     */
 
289
    public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis);
 
290
 
 
291
    /**
 
292
     * The minimum number of established connections that should be kept in the pool at all times. 
 
293
     * The connection pool can shrink below this number if validation queries fail and connections get closed. 
 
294
     * Default value is derived from {@link #getInitialSize()} (also see {@link #setTestWhileIdle(boolean)}
 
295
     * The idle pool will not shrink below this value during an eviction run, hence the number of actual connections
 
296
     * can be between {@link #getMinIdle()} and somewhere between {@link #getMaxIdle()} and {@link #getMaxActive()}
 
297
     * @return the minimum number of idle or established connections
 
298
     */
 
299
    public int getMinIdle();
 
300
    
 
301
    /**
 
302
     * The minimum number of established connections that should be kept in the pool at all times. 
 
303
     * The connection pool can shrink below this number if validation queries fail and connections get closed. 
 
304
     * Default value is derived from {@link #getInitialSize()} (also see {@link #setTestWhileIdle(boolean)}
 
305
     * The idle pool will not shrink below this value during an eviction run, hence the number of actual connections
 
306
     * can be between {@link #getMinIdle()} and somewhere between {@link #getMaxIdle()} and {@link #getMaxActive()}
 
307
     * 
 
308
     * @param minIdle the minimum number of idle or established connections
 
309
     */
 
310
    public void setMinIdle(int minIdle);
 
311
 
 
312
    /**
 
313
     * Returns the name of the connection pool. By default a JVM unique random name is assigned.
 
314
     * @return the name of the pool, should be unique in a JVM
 
315
     */
 
316
    public String getName();
 
317
    
 
318
    /**
 
319
     * Sets the name of the connection pool 
 
320
     * @param name the name of the pool, should be unique in a runtime JVM
 
321
     */
 
322
    public void setName(String name);
 
323
 
 
324
    /**
 
325
     * Property not used
 
326
     * @return unknown value
 
327
     */
 
328
    public int getNumTestsPerEvictionRun();
 
329
    
 
330
    /**
 
331
     * Property not used
 
332
     * @param numTestsPerEvictionRun parameter ignored.
 
333
     */
 
334
    public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun);
 
335
 
 
336
    /**
 
337
     * Returns the password used when establishing connections to the database.
 
338
     * @return the password in string format
 
339
     */
 
340
    public String getPassword();
 
341
    
 
342
    /**
 
343
     * Sets the password to establish the connection with.
 
344
     * The password will be included as a database property with the name 'password'.
 
345
     * @param password 
 
346
     * @see #getDbProperties()
 
347
     */
 
348
    public void setPassword(String password);
 
349
 
 
350
    /**
 
351
     * @see #getName()
 
352
     * @return name
 
353
     */
 
354
    public String getPoolName();
 
355
    
 
356
    /**
 
357
     * Returns the username used to establish the connection with
 
358
     * @return the username used to establish the connection with
 
359
     */
 
360
    public String getUsername();
 
361
 
 
362
    /**
 
363
     * Sets the username used to establish the connection with
 
364
     * It will also be a property called 'user' in the database properties.
 
365
     * @param username
 
366
     * @see #getDbProperties()
 
367
     */
 
368
    public void setUsername(String username);
 
369
 
 
370
 
 
371
    /**
 
372
     * boolean flag to remove abandoned connections if they exceed the removeAbandonedTimout. 
 
373
     * If set to true a connection is considered abandoned and eligible for removal if it has 
 
374
     * been in use longer than the {@link #getRemoveAbandonedTimeout()} and the condition for 
 
375
     * {@link #getAbandonWhenPercentageFull()} is met.
 
376
     * Setting this to true can recover db connections from applications that fail to close a connection. 
 
377
     * See also {@link #isLogAbandoned()} The default value is false.
 
378
     * @return true if abandoned connections can be closed and expelled out of the pool
 
379
     */
 
380
    public boolean isRemoveAbandoned();
 
381
    
 
382
    /**
 
383
     * boolean flag to remove abandoned connections if they exceed the removeAbandonedTimout. 
 
384
     * If set to true a connection is considered abandoned and eligible for removal if it has 
 
385
     * been in use longer than the {@link #getRemoveAbandonedTimeout()} and the condition for 
 
386
     * {@link #getAbandonWhenPercentageFull()} is met.
 
387
     * Setting this to true can recover db connections from applications that fail to close a connection. 
 
388
     * See also {@link #isLogAbandoned()} The default value is false.
 
389
     * @param removeAbandoned set to true if abandoned connections can be closed and expelled out of the pool
 
390
     */
 
391
    public void setRemoveAbandoned(boolean removeAbandoned);
 
392
 
 
393
    /**
 
394
     * The time in seconds before a connection can be considered abandoned.
 
395
     * The timer can be reset upon queries using an interceptor.
 
396
     * @param removeAbandonedTimeout the time in seconds before a used connection can be considered abandoned
 
397
     * @see org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer
 
398
     */
 
399
    public void setRemoveAbandonedTimeout(int removeAbandonedTimeout);
 
400
 
 
401
    /**
 
402
     * The time in seconds before a connection can be considered abandoned.
 
403
     * The timer can be reset upon queries using an interceptor.
 
404
     * @see org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer
 
405
     * @return the time in seconds before a used connection can be considered abandoned
 
406
     */ 
 
407
    public int getRemoveAbandonedTimeout();
 
408
 
 
409
    /**
 
410
     * The indication of whether objects will be validated before being borrowed from the pool. 
 
411
     * If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another. 
 
412
     * NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string. 
 
413
     * Default value is false
 
414
     * In order to have a more efficient validation, see {@link #setValidationInterval(long)}
 
415
     * @return true if the connection is to be validated upon borrowing a connection from the pool
 
416
     * @see #getValidationInterval()
 
417
     */
 
418
    public boolean isTestOnBorrow();
 
419
    
 
420
    /**
 
421
     * The indication of whether objects will be validated before being borrowed from the pool. 
 
422
     * If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another. 
 
423
     * NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string. 
 
424
     * Default value is false
 
425
     * In order to have a more efficient validation, see {@link #setValidationInterval(long)}
 
426
     * @param testOnBorrow set to true if validation should take place before a connection is handed out to the application
 
427
     * @see #getValidationInterval()
 
428
     */
 
429
    public void setTestOnBorrow(boolean testOnBorrow);
 
430
    
 
431
    /**
 
432
     * The indication of whether objects will be validated after being returned to the pool. 
 
433
     * If the object fails to validate, it will be dropped from the pool. 
 
434
     * NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string. 
 
435
     * Default value is false
 
436
     * In order to have a more efficient validation, see {@link #setValidationInterval(long)}
 
437
     * @return true if validation should take place after a connection is returned to the pool
 
438
     * @see #getValidationInterval()
 
439
     */
 
440
    public boolean isTestOnReturn();
 
441
 
 
442
    /**
 
443
     * The indication of whether objects will be validated after being returned to the pool. 
 
444
     * If the object fails to validate, it will be dropped from the pool. 
 
445
     * NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string. 
 
446
     * Default value is false
 
447
     * In order to have a more efficient validation, see {@link #setValidationInterval(long)}
 
448
     * @param testOnReturn true if validation should take place after a connection is returned to the pool
 
449
     * @see #getValidationInterval()
 
450
     */
 
451
    public void setTestOnReturn(boolean testOnReturn);
 
452
    
 
453
    
 
454
    /**
 
455
     * Set to true if query validation should take place while the connection is idle.
 
456
     * @return true if validation should take place during idle checks
 
457
     * @see #setTimeBetweenEvictionRunsMillis(int)
 
458
     */
 
459
    public boolean isTestWhileIdle();
 
460
    
 
461
    /**
 
462
     * Set to true if query validation should take place while the connection is idle.
 
463
     * @param testWhileIdle true if validation should take place during idle checks
 
464
     * @see #setTimeBetweenEvictionRunsMillis(int)
 
465
     */
 
466
    public void setTestWhileIdle(boolean testWhileIdle);
 
467
    
 
468
    /**
 
469
     * The number of milliseconds to sleep between runs of the idle connection validation, abandoned cleaner 
 
470
     * and idle pool resizing. This value should not be set under 1 second. 
 
471
     * It dictates how often we check for idle, abandoned connections, and how often we validate idle connection and resize the idle pool.
 
472
     * The default value is 5000 (5 seconds)
 
473
     * @return the sleep time in between validations in milliseconds
 
474
     */
 
475
    public int getTimeBetweenEvictionRunsMillis();
 
476
    
 
477
    /**
 
478
     * The number of milliseconds to sleep between runs of the idle connection validation, abandoned cleaner 
 
479
     * and idle pool resizing. This value should not be set under 1 second. 
 
480
     * It dictates how often we check for idle, abandoned connections, and how often we validate idle connection and resize the idle pool.
 
481
     * The default value is 5000 (5 seconds)
 
482
     * @param timeBetweenEvictionRunsMillis the sleep time in between validations in milliseconds
 
483
     */
 
484
    public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis);
 
485
    
 
486
    /**
 
487
     * The URL used to connect to the database
 
488
     * @return the configured URL for this connection pool
 
489
     * @see java.sql.Driver#connect(String, Properties)
 
490
     */
 
491
    public String getUrl();
 
492
    
 
493
    /**
 
494
     * Sets the URL used to connect to the database
 
495
     * @param url the configured URL for this connection pool
 
496
     * @see java.sql.Driver#connect(String, Properties)
 
497
     */
 
498
    public void setUrl(String url);
 
499
    
 
500
    /**
 
501
     * The SQL query that will be used to validate connections from this 
 
502
     * pool before returning them to the caller or pool. 
 
503
     * If specified, this query does not have to return any data, 
 
504
     * it just can't throw a SQLException. 
 
505
     * The default value is null. 
 
506
     * Example values are SELECT 1(mysql), 
 
507
     * select 1 from dual(oracle), 
 
508
     * SELECT 1(MS Sql Server)
 
509
     * @return the query used for validation or null if no validation is performed
 
510
     */
 
511
    public String getValidationQuery();
 
512
    
 
513
    /**
 
514
     * The SQL query that will be used to validate connections from this 
 
515
     * pool before returning them to the caller or pool. 
 
516
     * If specified, this query does not have to return any data, 
 
517
     * it just can't throw a SQLException. 
 
518
     * The default value is null. 
 
519
     * Example values are SELECT 1(mysql), 
 
520
     * select 1 from dual(oracle), 
 
521
     * SELECT 1(MS Sql Server)
 
522
     * @param validationQuery the query used for validation or null if no validation is performed
 
523
     */
 
524
    public void setValidationQuery(String validationQuery);
 
525
    
 
526
    /**
 
527
     * Return the name of the optional validator class - may be null.
 
528
     *  
 
529
     * @return the name of the optional validator class - may be null
 
530
     */
 
531
    public String getValidatorClassName();
 
532
    
 
533
    /**
 
534
     * Set the name for an optional validator class which will be used in place of test queries. If set to
 
535
     * null, standard validation will be used.
 
536
     * 
 
537
     * @param className the name of the optional validator class
 
538
     */
 
539
    public void setValidatorClassName(String className);
 
540
    
 
541
    /**
 
542
     * @return the optional validator object - may be null
 
543
     */
 
544
    public Validator getValidator();
 
545
    
 
546
    /**
 
547
     * Sets the validator object
 
548
     * If this is a non null object, it will be used as a validator instead of the validationQuery
 
549
     * If this is null, remove the usage of the validator.
 
550
     */
 
551
    public void setValidator(Validator validator);
 
552
 
 
553
    /**
 
554
     * avoid excess validation, only run validation at most at this frequency - time in milliseconds. 
 
555
     * If a connection is due for validation, but has been validated previously 
 
556
     * within this interval, it will not be validated again. 
 
557
     * The default value is 30000 (30 seconds).
 
558
     * @return the validation interval in milliseconds
 
559
     */
 
560
    public long getValidationInterval();
 
561
    
 
562
    /**
 
563
     * avoid excess validation, only run validation at most at this frequency - time in milliseconds. 
 
564
     * If a connection is due for validation, but has been validated previously 
 
565
     * within this interval, it will not be validated again. 
 
566
     * The default value is 30000 (30 seconds).
 
567
     * @param validationInterval the validation interval in milliseconds
 
568
     */
 
569
    public void setValidationInterval(long validationInterval);
 
570
    
 
571
    /**
 
572
     * A custom query to be run when a connection is first created. The default value is null.
 
573
     * This query only runs once per connection, and that is when a new connection is established to the database.
 
574
     * If this value is non null, it will replace the validation query during connection creation. 
 
575
     * @return the init SQL used to run against the DB or null if not set 
 
576
     */
 
577
    public String getInitSQL();
 
578
    
 
579
    /**
 
580
     * A custom query to be run when a connection is first created. The default value is null.
 
581
     * This query only runs once per connection, and that is when a new connection is established to the database.
 
582
     * If this value is non null, it will replace the validation query during connection creation. 
 
583
     * @param initSQL the init SQL used to run against the DB or null if no query should be executed 
 
584
     */
 
585
    public void setInitSQL(String initSQL);
 
586
 
 
587
    /**
 
588
     * Returns true if we should run the validation query when connecting to the database for the first time on a connection.
 
589
     * Normally this is always set to false, unless one wants to use the validationQuery as an init query.
 
590
     * @return true if we should run the validation query upon connect
 
591
     */
 
592
    public boolean isTestOnConnect();
 
593
 
 
594
    /**
 
595
     * Set to true if we should run the validation query when connecting to the database for the first time on a connection.
 
596
     * Normally this is always set to false, unless one wants to use the validationQuery as an init query.
 
597
     * Setting an {@link #setInitSQL(String)} will override this setting, as the init SQL will be used instead of the validation query
 
598
     * @param testOnConnect set to true if we should run the validation query upon connect
 
599
     */
 
600
    public void setTestOnConnect(boolean testOnConnect);
 
601
    
 
602
    /**
 
603
     * A semicolon separated list of classnames extending {@link org.apache.tomcat.jdbc.pool.JdbcInterceptor} class. 
 
604
     * These interceptors will be inserted as an interceptor into the chain of operations on a java.sql.Connection object.
 
605
     * Example interceptors are {@link org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer StatementFinalizer} to close all 
 
606
     * used statements during the session.
 
607
     * {@link org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer ResetAbandonedTimer} resets the timer upon every operation
 
608
     * on the connection or a statement.
 
609
     * {@link org.apache.tomcat.jdbc.pool.interceptor.ConnectionState ConnectionState} caches the auto commit, read only and catalog settings to avoid round trips to the DB.
 
610
     * The default value is null.
 
611
     * @return the interceptors that are used for connections.
 
612
     * Example format: 'ConnectionState(useEquals=true,fast=yes);ResetAbandonedTimer'
 
613
     */
 
614
    public String getJdbcInterceptors();
 
615
    
 
616
    /**
 
617
     * A semicolon separated list of classnames extending {@link org.apache.tomcat.jdbc.pool.JdbcInterceptor} class. 
 
618
     * These interceptors will be inserted as an interceptor into the chain of operations on a java.sql.Connection object.
 
619
     * Example interceptors are {@link org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer StatementFinalizer} to close all 
 
620
     * used statements during the session.
 
621
     * {@link org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer ResetAbandonedTimer} resets the timer upon every operation
 
622
     * on the connection or a statement.
 
623
     * {@link org.apache.tomcat.jdbc.pool.interceptor.ConnectionState ConnectionState} caches the auto commit, read only and catalog settings to avoid round trips to the DB.
 
624
     * The default value is null.
 
625
     * @param jdbcInterceptors the interceptors that are used for connections.
 
626
     * Example format: 'ConnectionState(useEquals=true,fast=yes);ResetAbandonedTimer'
 
627
     */
 
628
    public void setJdbcInterceptors(String jdbcInterceptors);
 
629
 
 
630
    /**
 
631
     * Returns the {@link #getJdbcInterceptors()} as an array of objects with properties and the classes.
 
632
     * @return an array of interceptors that have been configured
 
633
     */
 
634
    public InterceptorDefinition[] getJdbcInterceptorsAsArray();
 
635
 
 
636
    
 
637
    /**
 
638
     * If set to true, the connection pool creates a {@link org.apache.tomcat.jdbc.pool.jmx.ConnectionPoolMBean} object 
 
639
     * that can be registered with JMX to receive notifications and state about the pool.
 
640
     * The ConnectionPool object doesn't register itself, as there is no way to keep a static non changing ObjectName across JVM restarts.
 
641
     * @return true if the mbean object will be created upon startup.
 
642
     */
 
643
    public boolean isJmxEnabled();
 
644
 
 
645
    /**
 
646
     * If set to true, the connection pool creates a {@link org.apache.tomcat.jdbc.pool.jmx.ConnectionPoolMBean} object 
 
647
     * that can be registered with JMX to receive notifications and state about the pool.
 
648
     * The ConnectionPool object doesn't register itself, as there is no way to keep a static non changing ObjectName across JVM restarts.
 
649
     * @param jmxEnabled set to to if the mbean object should be created upon startup.
 
650
     */
 
651
    public void setJmxEnabled(boolean jmxEnabled);
 
652
 
 
653
    /**
 
654
     * Returns true if the pool sweeper is enabled for the connection pool.
 
655
     * The pool sweeper is enabled if any settings that require async intervention in the pool are turned on
 
656
     * <source>
 
657
        boolean result = getTimeBetweenEvictionRunsMillis()>0;
 
658
        result = result && (isRemoveAbandoned() && getRemoveAbandonedTimeout()>0);
 
659
        result = result || (isTestWhileIdle() && getValidationQuery()!=null);
 
660
        return result;
 
661
       </source> 
 
662
     *
 
663
     * @return true if a background thread is or will be enabled for this pool
 
664
     */
 
665
    public boolean isPoolSweeperEnabled();
 
666
 
 
667
    /**
 
668
     * Set to true if you wish the <code>ProxyConnection</code> class to use <code>String.equals</code> instead of 
 
669
     * <code>==</code> when comparing method names. 
 
670
     * This property does not apply to added interceptors as those are configured individually.
 
671
     * The default value is <code>false</code>.
 
672
     * @return true if pool uses {@link String#equals(Object)} instead of == when comparing method names on {@link java.sql.Connection} methods
 
673
     */
 
674
    public boolean isUseEquals();
 
675
 
 
676
    /**
 
677
     * Set to true if you wish the <code>ProxyConnection</code> class to use <code>String.equals</code> instead of 
 
678
     * <code>==</code> when comparing method names. 
 
679
     * This property does not apply to added interceptors as those are configured individually.
 
680
     * The default value is <code>false</code>.
 
681
     * @param useEquals set to true if the pool should use {@link String#equals(Object)} instead of ==
 
682
     * when comparing method names on {@link java.sql.Connection} methods
 
683
     */
 
684
    public void setUseEquals(boolean useEquals);
 
685
 
 
686
    /**
 
687
     * Time in milliseconds to keep this connection alive even when used. 
 
688
     * When a connection is returned to the pool, the pool will check to see if the 
 
689
     * ((now - time-when-connected) > maxAge) has been reached, and if so, 
 
690
     * it closes the connection rather than returning it to the pool. 
 
691
     * The default value is 0, which implies that connections will be left open and no 
 
692
     * age check will be done upon returning the connection to the pool.
 
693
     * This is a useful setting for database sessions that leak memory as it ensures that the session
 
694
     * will have a finite life span.
 
695
     * @return the time in milliseconds a connection will be open for when used
 
696
     */
 
697
    public long getMaxAge();
 
698
 
 
699
    /**
 
700
     * Time in milliseconds to keep this connection alive even when used. 
 
701
     * When a connection is returned to the pool, the pool will check to see if the 
 
702
     * ((now - time-when-connected) > maxAge) has been reached, and if so, 
 
703
     * it closes the connection rather than returning it to the pool. 
 
704
     * The default value is 0, which implies that connections will be left open and no 
 
705
     * age check will be done upon returning the connection to the pool.
 
706
     * This is a useful setting for database sessions that leak memory as it ensures that the session
 
707
     * will have a finite life span.
 
708
     * @param maxAge the time in milliseconds a connection will be open for when used
 
709
     */
 
710
    public void setMaxAge(long maxAge);
 
711
 
 
712
    /**
 
713
     * Return true if a lock should be used when operations are performed on the connection object.
 
714
     * Should be set to false unless you plan to have a background thread of your own doing idle and abandon checking
 
715
     * such as JMX clients. If the pool sweeper is enabled, then the lock will automatically be used regardless of this setting.
 
716
     * @return true if a lock is used.
 
717
     */
 
718
    public boolean getUseLock();
 
719
 
 
720
    /**
 
721
     * Set to true if a lock should be used when operations are performed on the connection object.
 
722
     * Should be set to false unless you plan to have a background thread of your own doing idle and abandon checking
 
723
     * such as JMX clients. If the pool sweeper is enabled, then the lock will automatically be used regardless of this setting.
 
724
     * @param useLock set to true if a lock should be used on connection operations
 
725
     */
 
726
    public void setUseLock(boolean useLock);
 
727
    
 
728
    /**
 
729
     * Similar to {@link #setRemoveAbandonedTimeout(int)} but instead of treating the connection
 
730
     * as abandoned, and potentially closing the connection, this simply logs the warning if 
 
731
     * {@link #isLogAbandoned()} returns true. If this value is equal or less than 0, no suspect 
 
732
     * checking will be performed. Suspect checking only takes place if the timeout value is larger than 0 and
 
733
     * the connection was not abandoned or if abandon check is disabled. If a connection is suspect a WARN message gets
 
734
     * logged and a JMX notification gets sent once. 
 
735
     * @param seconds - the amount of time in seconds that has to pass before a connection is marked suspect. 
 
736
     */
 
737
    public void setSuspectTimeout(int seconds);
 
738
    
 
739
    /**
 
740
     * Returns the time in seconds to pass before a connection is marked an abanoned suspect.
 
741
     * Any value lesser than or equal to 0 means the check is disabled. 
 
742
     * @return Returns the time in seconds to pass before a connection is marked an abanoned suspect.
 
743
     */
 
744
    public int getSuspectTimeout();
 
745
    
 
746
    /**
 
747
     * Injects a datasource that will be used to retrieve/create connections.
 
748
     * If a data source is set, the {@link PoolConfiguration#getUrl()} and {@link PoolConfiguration#getDriverClassName()} methods are ignored
 
749
     * and not used by the pool. If the {@link PoolConfiguration#getUsername()} and {@link PoolConfiguration#getPassword()}
 
750
     * values are set, the method {@link javax.sql.DataSource#getConnection(String, String)} method will be called instead of the
 
751
     * {@link javax.sql.DataSource#getConnection()} method.
 
752
     * If the data source implements {@link javax.sql.XADataSource} the methods 
 
753
     * {@link javax.sql.XADataSource#getXAConnection()} and {@link javax.sql.XADataSource#getXAConnection(String,String)}
 
754
     * will be invoked.  
 
755
     * @param ds the {@link javax.sql.DataSource} to be used for creating connections to be pooled.
 
756
     */
 
757
    public void setDataSource(Object ds);
 
758
    
 
759
    /**
 
760
     * Returns a datasource, if one exists that is being used to create connections.
 
761
     * This method will return null if the pool is using a {@link java.sql.Driver}
 
762
     * @return the {@link javax.sql.DataSource} to be used for creating connections to be pooled or null if a Driver is used.
 
763
     */
 
764
    public Object getDataSource();
 
765
    
 
766
    /**
 
767
     * Configure the connection pool to use a DataSource according to {@link PoolConfiguration#setDataSource(Object)}
 
768
     * But instead of injecting the object, specify the JNDI location.
 
769
     * After a successful JNDI look, the {@link PoolConfiguration#getDataSource()} will not return null. 
 
770
     * @param jndiDS -the JNDI string @TODO specify the rules here.
 
771
     */
 
772
    public void setDataSourceJNDI(String jndiDS);
 
773
    
 
774
    /**
 
775
     * Returns the JNDI string configured for data source usage.
 
776
     * @return the JNDI string or null if not set
 
777
     */
 
778
    public String getDataSourceJNDI();
 
779
    
 
780
    /**
 
781
     * Returns true if the call {@link DataSource#getConnection(String, String) getConnection(username,password)} is 
 
782
     * allowed. This is used for when the pool is used by an application accessing multiple schemas.
 
783
     * There is a performance impact turning this option on.
 
784
     * @return true if {@link DataSource#getConnection(String, String) getConnection(username,password)} is honored, false if it is ignored.
 
785
     */
 
786
    public boolean isAlternateUsernameAllowed();
 
787
    
 
788
    /**
 
789
     * Set to true if the call {@link DataSource#getConnection(String, String) getConnection(username,password)} is 
 
790
     * allowed and honored.. This is used for when the pool is used by an application accessing multiple schemas.
 
791
     * There is a performance impact turning this option on, even when not used due to username checks.
 
792
     * @param alternateUsernameAllowed - set true if {@link DataSource#getConnection(String, String) getConnection(username,password)} is honored, 
 
793
     * false if it is to be ignored.
 
794
     */
 
795
    public void setAlternateUsernameAllowed(boolean alternateUsernameAllowed);
 
796
    
 
797
 
 
798
}
 
 
b'\\ No newline at end of file'