001: package net.sourceforge.squirrel_sql.jdbcproxy;
002:
003: /*
004: * Copyright (C) 2006 Rob Manning
005: * manningr@users.sourceforge.net
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021:
022: import java.sql.CallableStatement;
023: import java.sql.Connection;
024: import java.sql.DatabaseMetaData;
025: import java.sql.PreparedStatement;
026: import java.sql.SQLException;
027: import java.sql.SQLWarning;
028: import java.sql.Savepoint;
029: import java.sql.Statement;
030: import java.util.Map;
031:
032: public class ProxyConnection implements Connection {
033:
034: Connection _con = null;
035: ProxyDatabaseMetaData _data = null;
036:
037: public ProxyConnection(Connection con) throws SQLException {
038: _con = con;
039: _data = new ProxyDatabaseMetaData(con.getMetaData());
040: }
041:
042: public int getHoldability() throws SQLException {
043: ProxyMethodManager.check("ProxyConnection", "getHoldability");
044: return _con.getHoldability();
045: }
046:
047: public int getTransactionIsolation() throws SQLException {
048: ProxyMethodManager.check("ProxyConnection",
049: "getTransactionIsolation");
050: return _con.getTransactionIsolation();
051: }
052:
053: public void clearWarnings() throws SQLException {
054: ProxyMethodManager.check("ProxyConnection", "clearWarnings");
055: _con.clearWarnings();
056: }
057:
058: public void close() throws SQLException {
059: ProxyMethodManager.printMethodsCalled();
060: ProxyMethodManager.check("ProxyConnection", "close");
061: _con.close();
062: }
063:
064: public void commit() throws SQLException {
065: ProxyMethodManager.check("ProxyConnection", "commit");
066: _con.commit();
067: }
068:
069: public void rollback() throws SQLException {
070: ProxyMethodManager.check("ProxyConnection", "rollback");
071: _con.rollback();
072: }
073:
074: public boolean getAutoCommit() throws SQLException {
075: ProxyMethodManager.check("ProxyConnection", "getAutoCommit");
076: return _con.getAutoCommit();
077: }
078:
079: public boolean isClosed() throws SQLException {
080: ProxyMethodManager.check("ProxyConnection", "isClosed");
081: return _con.isClosed();
082: }
083:
084: public boolean isReadOnly() throws SQLException {
085: ProxyMethodManager.check("ProxyConnection", "isReadOnly");
086: return _con.isReadOnly();
087: }
088:
089: public void setHoldability(int holdability) throws SQLException {
090: ProxyMethodManager.check("ProxyConnection", "setHoldability");
091: _con.setHoldability(holdability);
092: }
093:
094: public void setTransactionIsolation(int level) throws SQLException {
095: ProxyMethodManager.check("ProxyConnection",
096: "setTransactionIsolation");
097: _con.setTransactionIsolation(level);
098: }
099:
100: public void setAutoCommit(boolean autoCommit) throws SQLException {
101: ProxyMethodManager.check("ProxyConnection", "setAutoCommit");
102: _con.setAutoCommit(autoCommit);
103: }
104:
105: public void setReadOnly(boolean readOnly) throws SQLException {
106: ProxyMethodManager.check("ProxyConnection", "setReadOnly");
107: _con.setReadOnly(readOnly);
108: }
109:
110: public String getCatalog() throws SQLException {
111: ProxyMethodManager.check("ProxyConnection", "getCatalog");
112: return _con.getCatalog();
113: }
114:
115: public void setCatalog(String catalog) throws SQLException {
116: ProxyMethodManager.check("ProxyConnection", "setCatalog");
117: _con.setCatalog(catalog);
118: }
119:
120: public DatabaseMetaData getMetaData() throws SQLException {
121: ProxyMethodManager.check("ProxyConnection", "getMetaData");
122: return _data;
123: }
124:
125: public SQLWarning getWarnings() throws SQLException {
126: ProxyMethodManager.check("ProxyConnection", "getWarnings");
127: return _con.getWarnings();
128: }
129:
130: public Savepoint setSavepoint() throws SQLException {
131: ProxyMethodManager.check("ProxyConnection", "setSavepoint");
132: return _con.setSavepoint();
133: }
134:
135: public void releaseSavepoint(Savepoint savepoint)
136: throws SQLException {
137: ProxyMethodManager.check("ProxyConnection", "releaseSavepoint");
138: _con.releaseSavepoint(savepoint);
139: }
140:
141: public void rollback(Savepoint savepoint) throws SQLException {
142: ProxyMethodManager.check("ProxyConnection", "rollback");
143: _con.rollback(savepoint);
144: }
145:
146: public Statement createStatement() throws SQLException {
147: ProxyMethodManager.check("ProxyConnection", "createStatement");
148: return new ProxyStatement(this , _con.createStatement());
149: }
150:
151: public Statement createStatement(int resultSetType,
152: int resultSetConcurrency) throws SQLException {
153: ProxyMethodManager.check("ProxyConnection", "createStatement");
154: return new ProxyStatement(this , _con.createStatement(
155: resultSetType, resultSetConcurrency));
156: }
157:
158: public Statement createStatement(int resultSetType,
159: int resultSetConcurrency, int resultSetHoldability)
160: throws SQLException {
161: ProxyMethodManager.check("ProxyConnection", "createStatement");
162: return new ProxyStatement(this , _con.createStatement(
163: resultSetType, resultSetConcurrency,
164: resultSetHoldability));
165: }
166:
167: @SuppressWarnings("unchecked")
168: public Map getTypeMap() throws SQLException {
169: ProxyMethodManager.check("ProxyConnection", "getTypeMap");
170: return _con.getTypeMap();
171: }
172:
173: @SuppressWarnings("unchecked")
174: public void setTypeMap(Map map) throws SQLException {
175: ProxyMethodManager.check("ProxyConnection", "setTypeMap");
176: _con.setTypeMap(map);
177: }
178:
179: public String nativeSQL(String sql) throws SQLException {
180: ProxyMethodManager.check("ProxyConnection", "nativeSQL");
181: return _con.nativeSQL(sql);
182: }
183:
184: public CallableStatement prepareCall(String sql)
185: throws SQLException {
186: ProxyMethodManager.check("ProxyConnection", "prepareCall");
187: return _con.prepareCall(sql);
188: }
189:
190: public CallableStatement prepareCall(String sql, int resultSetType,
191: int resultSetConcurrency) throws SQLException {
192: ProxyMethodManager.check("ProxyConnection", "prepareCall");
193: return _con.prepareCall(sql, resultSetType,
194: resultSetConcurrency);
195: }
196:
197: public CallableStatement prepareCall(String sql, int resultSetType,
198: int resultSetConcurrency, int resultSetHoldability)
199: throws SQLException {
200: ProxyMethodManager.check("ProxyConnection", "prepareCall");
201: return _con.prepareCall(sql, resultSetType,
202: resultSetConcurrency, resultSetHoldability);
203: }
204:
205: public PreparedStatement prepareStatement(String sql)
206: throws SQLException {
207: ProxyMethodManager.check("ProxyConnection", "prepareStatement");
208: return _con.prepareStatement(sql);
209: }
210:
211: public PreparedStatement prepareStatement(String sql,
212: int autoGeneratedKeys) throws SQLException {
213: ProxyMethodManager.check("ProxyConnection", "prepareStatement");
214: return _con.prepareStatement(sql, autoGeneratedKeys);
215: }
216:
217: public PreparedStatement prepareStatement(String sql,
218: int resultSetType, int resultSetConcurrency)
219: throws SQLException {
220: ProxyMethodManager.check("ProxyConnection", "prepareStatement");
221: return _con.prepareStatement(sql, resultSetType,
222: resultSetConcurrency);
223: }
224:
225: public PreparedStatement prepareStatement(String sql,
226: int resultSetType, int resultSetConcurrency,
227: int resultSetHoldability) throws SQLException {
228: ProxyMethodManager.check("ProxyConnection", "prepareStatement");
229: return _con.prepareStatement(sql, resultSetType,
230: resultSetConcurrency, resultSetHoldability);
231: }
232:
233: public PreparedStatement prepareStatement(String sql,
234: int[] columnIndexes) throws SQLException {
235: ProxyMethodManager.check("ProxyConnection", "prepareStatement");
236: return _con.prepareStatement(sql, columnIndexes);
237: }
238:
239: public Savepoint setSavepoint(String name) throws SQLException {
240: ProxyMethodManager.check("ProxyConnection", "setSavepoint");
241: return _con.setSavepoint();
242: }
243:
244: public PreparedStatement prepareStatement(String sql,
245: String[] columnNames) throws SQLException {
246: ProxyMethodManager.check("ProxyConnection", "prepareStatement");
247: return _con.prepareStatement(sql, columnNames);
248: }
249:
250: }
|