001: package com.jat.integration.db.connectionpool;
002:
003: import java.sql.CallableStatement;
004: import java.sql.Connection;
005: import java.sql.DatabaseMetaData;
006: import java.sql.PreparedStatement;
007: import java.sql.SQLException;
008: import java.sql.SQLWarning;
009: import java.sql.Savepoint;
010: import java.sql.Statement;
011: import java.util.Map;
012:
013: /**
014: * <p>Title: JAT</p>
015: * <p>Description: </p>
016: * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
017: * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
018: * @author stf
019: * @version 1.0
020: * @since 1.2
021: */
022:
023: public class ConnectionWrapper implements Connection {
024:
025: public ConnectionWrapper(ConnectionPoolDataSource parent,
026: Connection con) {
027: this .dataSource = parent;
028: this .con = con;
029: }
030:
031: public void destroy() {
032: try {
033: this .con.close();
034: } catch (SQLException ex) {
035: }
036: }
037:
038: public void close() throws SQLException {
039: this .dataSource.releaseConnection(this );
040: }
041:
042: public Statement createStatement() throws SQLException {
043: return con.createStatement();
044: }
045:
046: public PreparedStatement prepareStatement(String sql)
047: throws SQLException {
048: return con.prepareStatement(sql);
049: }
050:
051: public CallableStatement prepareCall(String sql)
052: throws SQLException {
053: return con.prepareCall(sql);
054: }
055:
056: public String nativeSQL(String sql) throws SQLException {
057: return con.nativeSQL(sql);
058: }
059:
060: public void setAutoCommit(boolean autoCommit) throws SQLException {
061: con.setAutoCommit(autoCommit);
062: }
063:
064: public boolean getAutoCommit() throws SQLException {
065: return con.getAutoCommit();
066: }
067:
068: public void commit() throws SQLException {
069: con.commit();
070: }
071:
072: public void rollback() throws SQLException {
073: con.rollback();
074: }
075:
076: public boolean isClosed() throws SQLException {
077: return con.isClosed();
078: }
079:
080: public DatabaseMetaData getMetaData() throws SQLException {
081: return con.getMetaData();
082: }
083:
084: public void setReadOnly(boolean readOnly) throws SQLException {
085: con.setReadOnly(readOnly);
086: }
087:
088: public boolean isReadOnly() throws SQLException {
089: return con.isReadOnly();
090: }
091:
092: public void setCatalog(String catalog) throws SQLException {
093: con.setCatalog(catalog);
094: }
095:
096: public String getCatalog() throws SQLException {
097: return con.getCatalog();
098: }
099:
100: public void setTransactionIsolation(int level) throws SQLException {
101: con.setTransactionIsolation(level);
102: }
103:
104: public int getTransactionIsolation() throws SQLException {
105: return con.getTransactionIsolation();
106: }
107:
108: public SQLWarning getWarnings() throws SQLException {
109: return con.getWarnings();
110: }
111:
112: public void clearWarnings() throws SQLException {
113: con.clearWarnings();
114: }
115:
116: public Statement createStatement(int resultSetType,
117: int resultSetConcurrency) throws SQLException {
118: return con.createStatement(resultSetType, resultSetConcurrency);
119: }
120:
121: public PreparedStatement prepareStatement(String sql,
122: int resultSetType, int resultSetConcurrency)
123: throws SQLException {
124: return con.prepareStatement(sql, resultSetType,
125: resultSetConcurrency);
126: }
127:
128: public CallableStatement prepareCall(String sql, int resultSetType,
129: int resultSetConcurrency) throws SQLException {
130: return con
131: .prepareCall(sql, resultSetType, resultSetConcurrency);
132: }
133:
134: public Map getTypeMap() throws SQLException {
135: return con.getTypeMap();
136: }
137:
138: public void setTypeMap(Map map) throws SQLException {
139: con.setTypeMap(map);
140: }
141:
142: public void setHoldability(int holdability) throws SQLException {
143: con.setHoldability(holdability);
144: }
145:
146: public int getHoldability() throws SQLException {
147: return con.getHoldability();
148: }
149:
150: public Savepoint setSavepoint() throws SQLException {
151: return con.setSavepoint();
152: }
153:
154: public Savepoint setSavepoint(String name) throws SQLException {
155: return con.setSavepoint(name);
156: }
157:
158: public void rollback(Savepoint savepoint) throws SQLException {
159: con.rollback();
160: }
161:
162: public void releaseSavepoint(Savepoint savepoint)
163: throws SQLException {
164: con.releaseSavepoint(savepoint);
165: }
166:
167: public Statement createStatement(int resultSetType,
168: int resultSetConcurrency, int resultSetHoldability)
169: throws SQLException {
170: return con.createStatement(resultSetType, resultSetConcurrency,
171: resultSetHoldability);
172: }
173:
174: public PreparedStatement prepareStatement(String sql,
175: int resultSetType, int resultSetConcurrency,
176: int resultSetHoldability) throws SQLException {
177: return con.prepareStatement(sql, resultSetType,
178: resultSetConcurrency, resultSetHoldability);
179: }
180:
181: public CallableStatement prepareCall(String sql, int resultSetType,
182: int resultSetConcurrency, int resultSetHoldability)
183: throws SQLException {
184: return con.prepareCall(sql, resultSetType,
185: resultSetConcurrency, resultSetHoldability);
186: }
187:
188: public PreparedStatement prepareStatement(String sql,
189: int autoGeneratedKeys) throws SQLException {
190: return con.prepareStatement(sql, autoGeneratedKeys);
191: }
192:
193: public PreparedStatement prepareStatement(String sql,
194: int[] columnIndexes) throws SQLException {
195: return con.prepareStatement(sql, columnIndexes);
196: }
197:
198: public PreparedStatement prepareStatement(String sql,
199: String[] columnNames) throws SQLException {
200: return con.prepareStatement(sql, columnNames);
201: }
202:
203: private Connection con = null;
204: private ConnectionPoolDataSource dataSource = null;
205: }
|