KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > excalibur > datasource > Jdbc3Connection


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE.txt file.
7  */

8 package org.apache.avalon.excalibur.datasource;
9
10 import java.sql.CallableStatement JavaDoc;
11 import java.sql.Connection JavaDoc;
12 import java.sql.DatabaseMetaData JavaDoc;
13 import java.sql.PreparedStatement JavaDoc;
14 import java.sql.SQLException JavaDoc;
15 import java.sql.SQLWarning JavaDoc;
16 import java.sql.Statement JavaDoc;
17 import java.sql.Savepoint JavaDoc;
18 import java.util.Map JavaDoc;
19
20 /**
21  * The Connection object used in conjunction with the JdbcDataSource
22  * object.
23  *
24  * TODO: Implement a configurable closed end Pool, where the Connection
25  * acts like JDBC PooledConnections work. That means we can limit the
26  * total number of Connection objects that are created.
27  *
28  * @author <a HREF="mailto:bloritsch@apache.org">Berin Loritsch</a>
29  * @version CVS $Revision: 1.10 $ $Date: 2002/01/23 15:49:52 $
30  * @since 4.0
31  */

32 public class Jdbc3Connection
33     extends AbstractJdbcConnection
34 {
35     public Jdbc3Connection( final Connection JavaDoc connection, final String JavaDoc keepAlive )
36     {
37         super( connection, keepAlive );
38     }
39
40     public final Statement JavaDoc createStatement()
41         throws SQLException JavaDoc
42     {
43         final Statement JavaDoc temp = m_connection.createStatement();
44         m_lastUsed = System.currentTimeMillis();
45         return temp;
46     }
47
48     public final PreparedStatement JavaDoc prepareStatement( final String JavaDoc sql )
49         throws SQLException JavaDoc
50     {
51         final PreparedStatement JavaDoc temp = m_connection.prepareStatement( sql );
52         m_lastUsed = System.currentTimeMillis();
53         return temp;
54     }
55
56     public final CallableStatement JavaDoc prepareCall( final String JavaDoc sql )
57         throws SQLException JavaDoc
58     {
59         final CallableStatement JavaDoc temp = m_connection.prepareCall( sql );
60         m_lastUsed = System.currentTimeMillis();
61         return temp;
62     }
63
64     public final String JavaDoc nativeSQL( final String JavaDoc sql )
65         throws SQLException JavaDoc
66     {
67         return m_connection.nativeSQL( sql );
68     }
69
70     public final void setAutoCommit( final boolean autoCommit )
71         throws SQLException JavaDoc
72     {
73         m_connection.setAutoCommit( autoCommit );
74     }
75
76     public final boolean getAutoCommit()
77         throws SQLException JavaDoc
78     {
79         return m_connection.getAutoCommit();
80     }
81
82     public final void commit()
83         throws SQLException JavaDoc
84     {
85         m_connection.commit();
86         m_lastUsed = System.currentTimeMillis();
87     }
88
89     public final void rollback()
90         throws SQLException JavaDoc
91     {
92         m_connection.rollback();
93         m_lastUsed = System.currentTimeMillis();
94     }
95
96     public final DatabaseMetaData JavaDoc getMetaData()
97         throws SQLException JavaDoc
98     {
99         return m_connection.getMetaData();
100     }
101
102     public final void setReadOnly( final boolean readOnly )
103         throws SQLException JavaDoc
104     {
105         m_connection.setReadOnly( readOnly );
106     }
107
108     public final boolean isReadOnly()
109         throws SQLException JavaDoc
110     {
111         return m_connection.isReadOnly();
112     }
113
114     public final void setCatalog( final String JavaDoc catalog )
115         throws SQLException JavaDoc
116     {
117         m_connection.setCatalog( catalog );
118     }
119
120     public final String JavaDoc getCatalog()
121         throws SQLException JavaDoc
122     {
123         return m_connection.getCatalog();
124     }
125
126     public final void setTransactionIsolation( final int level )
127         throws SQLException JavaDoc
128     {
129         m_connection.setTransactionIsolation(level);
130     }
131
132     public final int getTransactionIsolation()
133         throws SQLException JavaDoc
134     {
135         return m_connection.getTransactionIsolation();
136     }
137
138     public final SQLWarning JavaDoc getWarnings()
139         throws SQLException JavaDoc
140     {
141         return m_connection.getWarnings();
142     }
143
144     public final void clearWarnings()
145         throws SQLException JavaDoc
146     {
147         m_connection.clearWarnings();
148     }
149
150     public final Statement JavaDoc createStatement( final int resultSetType,
151                                             final int resultSetConcurrency )
152         throws SQLException JavaDoc
153     {
154         final Statement JavaDoc temp = m_connection.createStatement(
155                 resultSetType, resultSetConcurrency
156         );
157
158         m_lastUsed = System.currentTimeMillis();
159         return temp;
160     }
161
162     public final PreparedStatement JavaDoc prepareStatement( final String JavaDoc sql,
163                                                final int resultSetType,
164                                                final int resultSetConcurrency )
165         throws SQLException JavaDoc
166     {
167         final PreparedStatement JavaDoc temp = m_connection.prepareStatement(
168                 sql, resultSetType, resultSetConcurrency
169         );
170
171         m_lastUsed = System.currentTimeMillis();
172         return temp;
173     }
174
175     public final CallableStatement JavaDoc prepareCall( final String JavaDoc sql,
176                                           final int resultSetType,
177                                           final int resultSetConcurrency )
178         throws SQLException JavaDoc
179     {
180         final CallableStatement JavaDoc temp = m_connection.prepareCall(
181             sql, resultSetType, resultSetConcurrency
182         );
183
184         m_lastUsed = System.currentTimeMillis();
185         return temp;
186     }
187
188     public final Map JavaDoc getTypeMap()
189         throws SQLException JavaDoc
190     {
191         return m_connection.getTypeMap();
192     }
193
194     public final void setTypeMap( final Map JavaDoc map )
195         throws SQLException JavaDoc
196     {
197          m_connection.setTypeMap( map );
198     }
199
200     public final void setHoldability(int holdability)
201         throws SQLException JavaDoc
202     {
203         m_connection.setHoldability(holdability);
204     }
205
206     public final int getHoldability()
207         throws SQLException JavaDoc
208     {
209         return m_connection.getHoldability();
210     }
211
212     public final Savepoint JavaDoc setSavepoint()
213         throws SQLException JavaDoc
214     {
215         return m_connection.setSavepoint();
216     }
217
218     public final Savepoint JavaDoc setSavepoint(String JavaDoc savepoint)
219         throws SQLException JavaDoc
220     {
221         return m_connection.setSavepoint(savepoint);
222     }
223
224     public final void rollback(Savepoint JavaDoc savepoint)
225         throws SQLException JavaDoc
226     {
227         m_connection.rollback(savepoint);
228         m_lastUsed = System.currentTimeMillis();
229     }
230
231     public final void releaseSavepoint(Savepoint JavaDoc savepoint)
232         throws SQLException JavaDoc
233     {
234         m_connection.releaseSavepoint(savepoint);
235     }
236
237     public final Statement JavaDoc createStatement(int resulSetType,
238                                            int resultSetConcurrency,
239                                            int resultSetHoldability)
240         throws SQLException JavaDoc
241     {
242         final Statement JavaDoc temp = m_connection.createStatement(
243                 resultSetType, resultSetConcurrency, resultSetHoldability
244         );
245
246         m_lastUsed = System.currentTimeMillis();
247         return temp;
248     }
249
250     public final PreparedStatement JavaDoc prepareStatement(String JavaDoc sql,
251                                         int resulSetType,
252                                         int resultSetConcurrency,
253                                         int resultSetHoldability)
254         throws SQLException JavaDoc
255     {
256         final PreparedStatement JavaDoc temp = m_connection.prepareStatement(
257             sql, resultSetType, resultSetConcurrency, resultSetHoldability
258         );
259
260         m_lastUsed = System.currentTimeMillis();
261         return temp;
262     }
263
264     public final CallableStatement JavaDoc prepareCall(String JavaDoc sql,
265                                         int resulSetType,
266                                         int resultSetConcurrency,
267                                         int resultSetHoldability)
268         throws SQLException JavaDoc
269     {
270         final CallableStatement JavaDoc temp = m_connection.prepareCall(
271             sql, resultSetType, resultSetConcurrency, resultSetHoldability
272         );
273
274         m_lastUsed = System.currentTimeMillis();
275         return temp;
276     }
277
278     public final PreparedStatement JavaDoc prepareStatement(String JavaDoc sql,
279                                         int autoGeneratedKeys)
280         throws SQLException JavaDoc
281     {
282         final PreparedStatement JavaDoc temp = m_connection.prepareStatement(
283                 sql, autoGeneratedKeys
284         );
285
286         m_lastUsed = System.currentTimeMillis();
287         return temp;
288     }
289
290     public final PreparedStatement JavaDoc prepareStatement(String JavaDoc sql,
291                                         int[] columnIndexes)
292         throws SQLException JavaDoc
293     {
294         final PreparedStatement JavaDoc temp = m_connection.prepareStatement(
295                 sql, columnIndexes
296         );
297
298         m_lastUsed = System.currentTimeMillis();
299         return temp;
300     }
301
302     public final PreparedStatement JavaDoc prepareStatement(String JavaDoc sql,
303                                         String JavaDoc[] columnNames)
304         throws SQLException JavaDoc
305     {
306         final PreparedStatement JavaDoc temp = m_connection.prepareStatement(
307                 sql, columnNames
308         );
309
310         m_lastUsed = System.currentTimeMillis();
311         return temp;
312     }
313 }
314
Popular Tags