2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 package com.mysql.clusterj.jdbc;
20 import com.mysql.jdbc.Connection;
21 import com.mysql.jdbc.ResultSetInternalMethods;
22 import com.mysql.jdbc.Statement;
24 import java.sql.SQLException;
25 import java.util.Properties;
27 /** This interceptor is called for execution of each statement of the associated connection.
28 * It is registered with the connection via the connection URL parameter
29 * statementInterceptors=com.mysql.clusterj.jdbc.StatementInterceptor.
30 * It must be used in conjunction with the ConnectionLifecycleInterceptor.
32 public class StatementInterceptor
33 implements com.mysql.jdbc.StatementInterceptorV2 {
35 /** The delegate for all methods. */
36 private InterceptorImpl interceptorImpl;
38 public void init(Connection connection, Properties properties) throws SQLException {
39 // find the interceptor if it's already registered; otherwise create it
40 this.interceptorImpl = InterceptorImpl.getInterceptorImpl(this, connection, properties);
43 public void destroy() {
44 interceptorImpl.destroy(this);
45 interceptorImpl = null;
48 public boolean executeTopLevelOnly() {
49 return interceptorImpl.executeTopLevelOnly();
52 public ResultSetInternalMethods postProcess(String sql, Statement statement,
53 ResultSetInternalMethods result, Connection connection, int arg4,
54 boolean arg5, boolean arg6, SQLException sqlException) throws SQLException {
55 return interceptorImpl.postProcess(sql, statement,
56 result, connection, arg4,
57 arg5, arg6, sqlException);
60 public ResultSetInternalMethods preProcess(String sql, Statement statement,
61 Connection connection) throws SQLException {
62 return interceptorImpl.preProcess(sql, statement, connection);