KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > amber > jdbc > AmberConnectionImpl


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.amber.jdbc;
31
32 import java.sql.*;
33 import java.util.Map JavaDoc;
34
35 /**
36  * Wrapper of the JDBC Connection.
37  */

38 public class AmberConnectionImpl implements Connection {
39   private Connection _conn;
40
41   /**
42    * Returns the underlying connection.
43    */

44   public Connection getConnection()
45   {
46     return _conn;
47   }
48
49   /**
50    * JDBC api to return the connection's catalog.
51    *
52    * @return the JDBC catalog.
53    */

54   public String JavaDoc getCatalog()
55     throws SQLException
56   {
57     return getConnection().getCatalog();
58   }
59
60   /**
61    * Sets the JDBC catalog.
62    */

63   public void setCatalog(String JavaDoc catalog)
64     throws SQLException
65   {
66     getConnection().setCatalog(catalog);
67   }
68
69   /**
70    * Gets the connection's metadata.
71    */

72   public DatabaseMetaData getMetaData()
73     throws SQLException
74   {
75     return getConnection().getMetaData();
76   }
77
78   /**
79    * Returns the connection's type map.
80    */

81   public Map JavaDoc getTypeMap()
82     throws SQLException
83   {
84     return getConnection().getTypeMap();
85   }
86
87   /**
88    * Sets the connection's type map.
89    */

90   public void setTypeMap(Map JavaDoc<String JavaDoc,Class JavaDoc<?>> map)
91     throws SQLException
92   {
93     getConnection().setTypeMap(map);
94   }
95
96   /**
97    * Calls the nativeSQL method for the connection.
98    */

99   public String JavaDoc nativeSQL(String JavaDoc sql)
100     throws SQLException
101   {
102     return getConnection().nativeSQL(sql);
103   }
104
105   public int getTransactionIsolation()
106     throws SQLException
107   {
108     return getConnection().getTransactionIsolation();
109   }
110
111   public void setTransactionIsolation(int isolation)
112     throws SQLException
113   {
114     getConnection().setTransactionIsolation(isolation);
115   }
116
117   public SQLWarning getWarnings()
118     throws SQLException
119   {
120     return getConnection().getWarnings();
121   }
122
123   public void clearWarnings()
124     throws SQLException
125   {
126     getConnection().clearWarnings();
127   }
128
129   public void setReadOnly(boolean readOnly)
130     throws SQLException
131   {
132     getConnection().setReadOnly(readOnly);
133   }
134
135   public boolean isReadOnly()
136     throws SQLException
137   {
138     return getConnection().isReadOnly();
139   }
140
141   /**
142    * JDBC api to create a new statement. Any SQL exception thrown here
143    * will make the connection invalid, i.e. it can't be put back into
144    * the pool.
145    *
146    * @return a new JDBC statement.
147    */

148   public Statement createStatement()
149     throws SQLException
150   {
151     return getConnection().createStatement();
152   }
153
154   /**
155    * JDBC api to create a new statement. Any SQL exception thrown here
156    * will make the connection invalid, i.e. it can't be put back into
157    * the pool.
158    *
159    * @return a new JDBC statement.
160    */

161   public Statement createStatement(int resultSetType, int resultSetConcurrency)
162     throws SQLException
163   {
164     return getConnection().createStatement(resultSetType, resultSetConcurrency);
165   }
166   
167   public Statement createStatement(int resultSetType,
168                                    int resultSetConcurrency,
169                                    int resultSetHoldability)
170     throws SQLException
171   {
172     return getConnection().createStatement(resultSetType,
173                        resultSetConcurrency,
174                        resultSetHoldability);
175   }
176
177
178   public PreparedStatement prepareStatement(String JavaDoc sql)
179     throws SQLException
180   {
181     return getConnection().prepareStatement(sql);
182   }
183   
184   public PreparedStatement prepareStatement(String JavaDoc sql,
185                                             int resultSetType)
186     throws SQLException
187   {
188     return getConnection().prepareStatement(sql, resultSetType);
189   }
190
191   public PreparedStatement prepareStatement(String JavaDoc sql, int resultSetType,
192                         int resultSetConcurrency)
193     throws SQLException
194   {
195     return getConnection().prepareStatement(sql, resultSetType,
196                         resultSetConcurrency);
197   }
198
199   public PreparedStatement prepareStatement(String JavaDoc sql,
200                                             int resultSetType,
201                                             int resultSetConcurrency,
202                                             int resultSetHoldability)
203     throws SQLException
204   {
205     return getConnection().prepareStatement(sql, resultSetType,
206                         resultSetConcurrency,
207                         resultSetHoldability);
208   }
209   
210   public PreparedStatement prepareStatement(String JavaDoc sql,
211                                             int []columnIndexes)
212     throws SQLException
213   {
214     return getConnection().prepareStatement(sql, columnIndexes);
215   }
216   
217   public PreparedStatement prepareStatement(String JavaDoc sql,
218                                             String JavaDoc []columnNames)
219     throws SQLException
220   {
221     return getConnection().prepareStatement(sql, columnNames);
222   }
223
224   public CallableStatement prepareCall(String JavaDoc sql)
225     throws SQLException
226   {
227     return getConnection().prepareCall(sql);
228   }
229
230   public CallableStatement prepareCall(String JavaDoc sql, int resultSetType,
231                        int resultSetConcurrency)
232     throws SQLException
233   {
234     return getConnection().prepareCall(sql, resultSetType,
235                        resultSetConcurrency);
236   }
237
238   public CallableStatement prepareCall(String JavaDoc sql,
239                                        int resultSetType,
240                                        int resultSetConcurrency,
241                                        int resultSetHoldability)
242     throws SQLException
243   {
244     return getConnection().prepareCall(sql, resultSetType,
245                        resultSetConcurrency,
246                        resultSetHoldability);
247   }
248
249   public boolean getAutoCommit()
250     throws SQLException
251   {
252     return getConnection().getAutoCommit();
253   }
254
255   public void setAutoCommit(boolean autoCommit)
256     throws SQLException
257   {
258     getConnection().setAutoCommit(autoCommit);
259   }
260
261   public void commit()
262     throws SQLException
263   {
264     getConnection().commit();
265   }
266
267   public void rollback()
268     throws SQLException
269   {
270     getConnection().rollback();
271   }
272
273   /**
274    * Returns true if the connection is closed.
275    */

276   public boolean isClosed()
277     throws SQLException
278   {
279     return getConnection().isClosed();
280   }
281
282   /**
283    * Reset the connection and return the underlying JDBC connection to
284    * the pool.
285    */

286   public void close() throws SQLException
287   {
288     getConnection().close();
289   }
290
291   public void setHoldability(int hold)
292     throws SQLException
293   {
294     getConnection().setHoldability(hold);
295   }
296
297   public int getHoldability()
298     throws SQLException
299   {
300     return getConnection().getHoldability();
301   }
302
303   public Savepoint setSavepoint()
304     throws SQLException
305   {
306     return getConnection().setSavepoint();
307   }
308
309   public Savepoint setSavepoint(String JavaDoc name)
310     throws SQLException
311   {
312     return getConnection().setSavepoint(name);
313   }
314
315   public void releaseSavepoint(Savepoint savepoint)
316     throws SQLException
317   {
318     getConnection().releaseSavepoint(savepoint);
319   }
320
321   public void rollback(Savepoint savepoint)
322     throws SQLException
323   {
324     getConnection().rollback(savepoint);
325   }
326
327   public String JavaDoc toString()
328   {
329     return "AmberConnection[" + _conn + "]";
330   }
331 }
332
Popular Tags