01: /*
02: * Distributed as part of c3p0 v.0.9.1.2
03: *
04: * Copyright (C) 2005 Machinery For Change, Inc.
05: *
06: * Author: Steve Waldman <swaldman@mchange.com>
07: *
08: * This library is free software; you can redistribute it and/or modify
09: * it under the terms of the GNU Lesser General Public License version 2.1, as
10: * published by the Free Software Foundation.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public License
18: * along with this software; see the file LICENSE. If not, write to the
19: * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20: * Boston, MA 02111-1307, USA.
21: */
22:
23: package com.mchange.v2.c3p0;
24:
25: import java.sql.Statement;
26: import java.sql.SQLException;
27: import java.lang.reflect.Method;
28: import java.lang.reflect.InvocationTargetException;
29:
30: /**
31: * <p><b>Most clients need never use or know about this interface -- c3p0-provided Statements
32: * can be treated like any other Statement.</b></p>
33: *
34: * <p>An interface implemented by proxy Connections returned
35: * by c3p0 PooledDataSources. It provides protected access to the underlying
36: * dbms-vendor specific Connection, which may be useful if you want to
37: * access non-standard API offered by your jdbc driver.
38: */
39: public interface C3P0ProxyStatement extends Statement {
40: /**
41: * A token representing an unwrapped, unproxied jdbc Connection
42: * for use in {@link #rawStatementOperation}
43: */
44: public final static Object RAW_STATEMENT = new Object();
45:
46: /**
47: * <p>Allows one to work with the unproxied, raw vendor-provided Statement . Some
48: * database companies never got over the "common interfaces mean
49: * no more vendor lock-in!" thing, and offer non-standard API
50: * on their Statements. This method permits you to "pierce" the
51: * connection-pooling layer to call non-standard methods on the
52: * original Statement, or to pass the original Statement to
53: * functions that are not implementation neutral.</p>
54: *
55: * <p>To use this functionality, you'll need to cast a Statement
56: * retrieved from a c3p0-provided Connection to a
57: * C3P0ProxyStatement.</p>
58: *
59: * <p>This method works by making a reflective call of method <tt>m</tt> on
60: * Object <tt>target</tt> (which may be null for static methods), passing
61: * and argument list <tt>args</tt>. For the method target, or for any argument,
62: * you may substitute the special token <tt>C3P0ProxyStatement.RAW_STATEMENT</tt></p>
63: *
64: * <p>Any ResultSets returned by the operation will be proxied
65: * and c3p0-managed, meaning that these resources will be automatically closed
66: * if the user does not close them first when this Statement is closed or checked
67: * into the statement cache. <b>Any other resources returned by the operation are the user's
68: * responsibility to clean up!</b></p>
69: *
70: * <p>If you have turned statement pooling on, incautious use of this method can corrupt the
71: * PreparedStatement cache, by breaking the invariant
72: * that all cached PreparedStatements should be equivalent to a PreparedStatement newly created
73: * with the same arguments to prepareStatement(...) or prepareCall(...). If your vendor supplies API
74: * that allows you to modify the state or configuration of a Statement in some nonstandard way,
75: * and you do not undo this modification prior to closing the Statement or the Connection that
76: * prepared it, future preparers of the same Statement may or may not see your modification,
77: * depending on your use of the cache. Thus, it is inadvisable to use this method to call
78: * nonstandard mutators on PreparedStatements if statement pooling is turned on..
79: */
80: public Object rawStatementOperation(Method m, Object target,
81: Object[] args) throws IllegalAccessException,
82: IllegalArgumentException, InvocationTargetException,
83: SQLException;
84: }
|