001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.amber.jdbc;
031:
032: import java.sql.*;
033: import java.util.Map;
034: import java.util.Properties;
035:
036: /**
037: * Wrapper of the JDBC Connection.
038: */
039: public class AmberConnectionImpl implements Connection {
040: private Connection _conn;
041:
042: /**
043: * Returns the underlying connection.
044: */
045: public Connection getConnection() {
046: return _conn;
047: }
048:
049: /**
050: * JDBC api to return the connection's catalog.
051: *
052: * @return the JDBC catalog.
053: */
054: public String getCatalog() throws SQLException {
055: return getConnection().getCatalog();
056: }
057:
058: /**
059: * Sets the JDBC catalog.
060: */
061: public void setCatalog(String catalog) throws SQLException {
062: getConnection().setCatalog(catalog);
063: }
064:
065: /**
066: * Gets the connection's metadata.
067: */
068: public DatabaseMetaData getMetaData() throws SQLException {
069: return getConnection().getMetaData();
070: }
071:
072: /**
073: * Returns the connection's type map.
074: */
075: public Map getTypeMap() throws SQLException {
076: return getConnection().getTypeMap();
077: }
078:
079: /**
080: * Sets the connection's type map.
081: */
082: public void setTypeMap(Map<String, Class<?>> map)
083: throws SQLException {
084: getConnection().setTypeMap(map);
085: }
086:
087: /**
088: * Calls the nativeSQL method for the connection.
089: */
090: public String nativeSQL(String sql) throws SQLException {
091: return getConnection().nativeSQL(sql);
092: }
093:
094: public int getTransactionIsolation() throws SQLException {
095: return getConnection().getTransactionIsolation();
096: }
097:
098: public void setTransactionIsolation(int isolation)
099: throws SQLException {
100: getConnection().setTransactionIsolation(isolation);
101: }
102:
103: public SQLWarning getWarnings() throws SQLException {
104: return getConnection().getWarnings();
105: }
106:
107: public void clearWarnings() throws SQLException {
108: getConnection().clearWarnings();
109: }
110:
111: public void setReadOnly(boolean readOnly) throws SQLException {
112: getConnection().setReadOnly(readOnly);
113: }
114:
115: public boolean isReadOnly() throws SQLException {
116: return getConnection().isReadOnly();
117: }
118:
119: /**
120: * JDBC api to create a new statement. Any SQL exception thrown here
121: * will make the connection invalid, i.e. it can't be put back into
122: * the pool.
123: *
124: * @return a new JDBC statement.
125: */
126: public Statement createStatement() throws SQLException {
127: return getConnection().createStatement();
128: }
129:
130: /**
131: * JDBC api to create a new statement. Any SQL exception thrown here
132: * will make the connection invalid, i.e. it can't be put back into
133: * the pool.
134: *
135: * @return a new JDBC statement.
136: */
137: public Statement createStatement(int resultSetType,
138: int resultSetConcurrency) throws SQLException {
139: return getConnection().createStatement(resultSetType,
140: resultSetConcurrency);
141: }
142:
143: public Statement createStatement(int resultSetType,
144: int resultSetConcurrency, int resultSetHoldability)
145: throws SQLException {
146: return getConnection().createStatement(resultSetType,
147: resultSetConcurrency, resultSetHoldability);
148: }
149:
150: public PreparedStatement prepareStatement(String sql)
151: throws SQLException {
152: return getConnection().prepareStatement(sql);
153: }
154:
155: public PreparedStatement prepareStatement(String sql,
156: int resultSetType) throws SQLException {
157: return getConnection().prepareStatement(sql, resultSetType);
158: }
159:
160: public PreparedStatement prepareStatement(String sql,
161: int resultSetType, int resultSetConcurrency)
162: throws SQLException {
163: return getConnection().prepareStatement(sql, resultSetType,
164: resultSetConcurrency);
165: }
166:
167: public PreparedStatement prepareStatement(String sql,
168: int resultSetType, int resultSetConcurrency,
169: int resultSetHoldability) throws SQLException {
170: return getConnection().prepareStatement(sql, resultSetType,
171: resultSetConcurrency, resultSetHoldability);
172: }
173:
174: public PreparedStatement prepareStatement(String sql,
175: int[] columnIndexes) throws SQLException {
176: return getConnection().prepareStatement(sql, columnIndexes);
177: }
178:
179: public PreparedStatement prepareStatement(String sql,
180: String[] columnNames) throws SQLException {
181: return getConnection().prepareStatement(sql, columnNames);
182: }
183:
184: public CallableStatement prepareCall(String sql)
185: throws SQLException {
186: return getConnection().prepareCall(sql);
187: }
188:
189: public CallableStatement prepareCall(String sql, int resultSetType,
190: int resultSetConcurrency) throws SQLException {
191: return getConnection().prepareCall(sql, resultSetType,
192: resultSetConcurrency);
193: }
194:
195: public CallableStatement prepareCall(String sql, int resultSetType,
196: int resultSetConcurrency, int resultSetHoldability)
197: throws SQLException {
198: return getConnection().prepareCall(sql, resultSetType,
199: resultSetConcurrency, resultSetHoldability);
200: }
201:
202: public boolean getAutoCommit() throws SQLException {
203: return getConnection().getAutoCommit();
204: }
205:
206: public void setAutoCommit(boolean autoCommit) throws SQLException {
207: getConnection().setAutoCommit(autoCommit);
208: }
209:
210: public void commit() throws SQLException {
211: getConnection().commit();
212: }
213:
214: public void rollback() throws SQLException {
215: getConnection().rollback();
216: }
217:
218: /**
219: * Returns true if the connection is closed.
220: */
221: public boolean isClosed() throws SQLException {
222: return getConnection().isClosed();
223: }
224:
225: /**
226: * Reset the connection and return the underlying JDBC connection to
227: * the pool.
228: */
229: public void close() throws SQLException {
230: getConnection().close();
231: }
232:
233: public void setHoldability(int hold) throws SQLException {
234: getConnection().setHoldability(hold);
235: }
236:
237: public int getHoldability() throws SQLException {
238: return getConnection().getHoldability();
239: }
240:
241: public Savepoint setSavepoint() throws SQLException {
242: return getConnection().setSavepoint();
243: }
244:
245: public Savepoint setSavepoint(String name) throws SQLException {
246: return getConnection().setSavepoint(name);
247: }
248:
249: public void releaseSavepoint(Savepoint savepoint)
250: throws SQLException {
251: getConnection().releaseSavepoint(savepoint);
252: }
253:
254: public void rollback(Savepoint savepoint) throws SQLException {
255: getConnection().rollback(savepoint);
256: }
257:
258: public String toString() {
259: return "AmberConnection[" + _conn + "]";
260: }
261:
262: public Clob createClob() throws SQLException {
263: throw new UnsupportedOperationException("Not supported yet.");
264: }
265:
266: public Blob createBlob() throws SQLException {
267: throw new UnsupportedOperationException("Not supported yet.");
268: }
269:
270: public NClob createNClob() throws SQLException {
271: throw new UnsupportedOperationException("Not supported yet.");
272: }
273:
274: public SQLXML createSQLXML() throws SQLException {
275: throw new UnsupportedOperationException("Not supported yet.");
276: }
277:
278: public boolean isValid(int timeout) throws SQLException {
279: throw new UnsupportedOperationException("Not supported yet.");
280: }
281:
282: public void setClientInfo(String name, String value)
283: throws SQLClientInfoException {
284: throw new UnsupportedOperationException("Not supported yet.");
285: }
286:
287: public void setClientInfo(Properties properties)
288: throws SQLClientInfoException {
289: throw new UnsupportedOperationException("Not supported yet.");
290: }
291:
292: public String getClientInfo(String name) throws SQLException {
293: throw new UnsupportedOperationException("Not supported yet.");
294: }
295:
296: public Properties getClientInfo() throws SQLException {
297: throw new UnsupportedOperationException("Not supported yet.");
298: }
299:
300: public Array createArrayOf(String typeName, Object[] elements)
301: throws SQLException {
302: throw new UnsupportedOperationException("Not supported yet.");
303: }
304:
305: public Struct createStruct(String typeName, Object[] attributes)
306: throws SQLException {
307: throw new UnsupportedOperationException("Not supported yet.");
308: }
309:
310: public <T> T unwrap(Class<T> iface) throws SQLException {
311: throw new UnsupportedOperationException("Not supported yet.");
312: }
313:
314: public boolean isWrapperFor(Class<?> iface) throws SQLException {
315: throw new UnsupportedOperationException("Not supported yet.");
316: }
317: }
|