KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nemesis > forum > util > jdbc > DbConnectionDefaultPool


1 /*
2  * NEMESIS-FORUM.
3  * Copyright (C) 2002 David Laurent(lithium2@free.fr). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  *
7  * Copyright (C) 2001 Yasna.com. All rights reserved.
8  *
9  * Copyright (C) 2000 CoolServlets.com. All rights reserved.
10  *
11  * NEMESIS-FORUM. is free software; you can redistribute it and/or
12  * modify it under the terms of the Apache Software License, Version 1.1,
13  * or (at your option) any later version.
14  *
15  * NEMESIS-FORUM core framework, NEMESIS-FORUM backoffice, NEMESIS-FORUM frontoffice
16  * application are parts of NEMESIS-FORUM and are distributed under
17  * same terms of licence.
18  *
19  *
20  * NEMESIS-FORUM includes software developed by the Apache Software Foundation (http://www.apache.org/)
21  * and software developed by CoolServlets.com (http://www.coolservlets.com).
22  * and software developed by Yasna.com (http://www.yasna.com).
23  *
24  */

25 package org.nemesis.forum.util.jdbc;
26
27 import java.io.IOException JavaDoc;
28 import java.sql.*;
29 import java.util.Date JavaDoc;
30 import java.util.Map JavaDoc;
31
32 import org.apache.commons.logging.Log;
33 import org.apache.commons.logging.LogFactory;
34 import org.nemesis.forum.config.ConfigLoader;
35
36 /**
37  * Default connection provider. It uses the excellent connection pool
38  * available from http://www.javaexchange.com. This connection provider is a
39  * a good choice unless you can use a container-managed one.
40  *
41  *
42  * <p>there is a compile-time dependencies on the
43  * <code>java.sql.Connection</code> class, which changed between JDK 1.3 and
44  * JDK 1.4.</p>
45  */

46 public class DbConnectionDefaultPool extends DbConnectionProvider {
47
48     static protected Log log = LogFactory.getLog(DbConnectionDefaultPool.class);
49
50     private static final boolean POOLED = true;
51
52     private ConnectionPool connectionPool = null;
53     //private Properties props;
54
//private Properties propDescriptions;
55

56     private Object JavaDoc initLock = new Object JavaDoc();
57
58     public DbConnectionDefaultPool() {
59
60     }
61
62     /**
63      * Returns a database connection.
64      */

65     public Connection getConnection() {
66         if (connectionPool == null) {
67             //block until the init has been done
68
synchronized (initLock) {
69                 //if still null, something has gone wrong
70
if (connectionPool == null) {
71                     log.error(
72                         "Warning: DbConnectionDefaultPool.getConnection() was "
73                             + "called when the internal pool has not been initialized.");
74                     return null;
75                 }
76             }
77         }
78         return new ConnectionWrapper(connectionPool.getConnection(), connectionPool);
79     }
80
81     /**
82      * Starts the pool.
83      */

84     protected void start() {
85         //acquire lock so that no connections can be returned.
86
synchronized (initLock) {
87             //Get properties
88
String JavaDoc driver = ConfigLoader.getInstance().getConfig().getJDBCProviderProperties().getProperty("driver");
89             String JavaDoc server = ConfigLoader.getInstance().getConfig().getJDBCProviderProperties().getProperty("url");
90             String JavaDoc username = ConfigLoader.getInstance().getConfig().getJDBCProviderProperties().getProperty("username");
91             String JavaDoc password = ConfigLoader.getInstance().getConfig().getJDBCProviderProperties().getProperty("password");
92             int minConnections = 1, maxConnections = 5;
93             double connectionTimeout = 0.1;
94             
95             try {
96                 
97                         
98             minConnections = Integer.parseInt(ConfigLoader.getInstance().getConfig().getJDBCProviderProperties().getProperty("minConnections"));
99             maxConnections = Integer.parseInt(ConfigLoader.getInstance().getConfig().getJDBCProviderProperties().getProperty("maxConnections"));
100             connectionTimeout = Double.parseDouble(ConfigLoader.getInstance().getConfig().getJDBCProviderProperties().getProperty("connectionTimeout"));
101             
102             } catch (Exception JavaDoc e) {
103                 log.error("your config is malformed",e);
104             }
105             
106             try {
107                 connectionPool =
108                     new ConnectionPool(
109                         driver,
110                         server,
111                         username,
112                         password,
113                         minConnections,
114                         maxConnections,
115                         connectionTimeout);
116             } catch (IOException JavaDoc ioe) {
117                 log.error("Error starting DbConnectionDefaultPool: " , ioe);
118             }
119         }
120     }
121
122     /**
123      * Restarts the pool to take into account any property changes.
124      */

125     protected void restart() {
126         //Kill off pool.
127
destroy();
128         //Start a new pool.
129
start();
130     }
131
132     /**
133      * Destroys the connection pool.
134      */

135     protected void destroy() {
136         if (connectionPool != null) {
137             try {
138                 connectionPool.destroy(1);
139             } catch (Exception JavaDoc e) {
140                 log.error("",e);
141             }
142         }
143         //Release reference to connectionPool
144
connectionPool = null;
145     }
146
147     /**
148      * DbConnectionBroker
149      * @version 1.0.11 12/7/99
150      * @author Marc A. Mnich
151      *
152      * ----------------------------------------
153      * Modified June 18, 2000 by Matt Tucker
154      * Changes:
155      * - New package name, class name to make it nice to embed as
156      * an internal class.
157      * - Source code reformatting.
158      * - Added more error handling code in constructor, createConn method
159      * so that more information is given to Yazd users.
160      * DbConnectionBroker rules! Download it from javaexchange.com
161      * ----------------------------------------
162      *
163      * DbConnectionBroker
164      * A servlet-based broker for database connections.
165      * Creates and manages a pool of database connections.
166      * @version 1.0.11 12/7/99
167      * @author Marc A. Mnich
168      */

169     private class ConnectionPool implements Runnable JavaDoc {
170         private Thread JavaDoc runner;
171
172         private Connection[] connPool;
173         private int[] connStatus;
174
175         private long[] connLockTime, connCreateDate;
176         private String JavaDoc[] connID;
177         private String JavaDoc dbDriver, dbServer, dbLogin, dbPassword;
178         private int currConnections, connLast, minConns, maxConns, maxConnMSec;
179
180         //available: set to false on destroy, checked by getConnection()
181
private boolean available = true;
182
183         private SQLWarning currSQLWarning;
184         private String JavaDoc pid;
185
186         /**
187          * Creates a new Connection Broker<br>
188          * dbDriver: JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'<br>
189          * dbServer: JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'<br>
190          * dbLogin: Database login name. e.g. 'Scott'<br>
191          * dbPassword: Database password. e.g. 'Tiger'<br>
192          * minConns: Minimum number of connections to start with.<br>
193          * maxConns: Maximum number of connections in dynamic pool.<br>
194          * logFileString: Absolute path name for log file. e.g. 'c:\temp\mylog.log' <br>
195          * maxConnTime: Time in days between connection resets. (Reset does a basic cleanup)<br>
196          */

197         public ConnectionPool(
198             String JavaDoc dbDriver,
199             String JavaDoc dbServer,
200             String JavaDoc dbLogin,
201             String JavaDoc dbPassword,
202             int minConns,
203             int maxConns,
204             double maxConnTime)
205             throws IOException JavaDoc {
206             connPool = new Connection[maxConns];
207             connStatus = new int[maxConns];
208             connLockTime = new long[maxConns];
209             connCreateDate = new long[maxConns];
210             connID = new String JavaDoc[maxConns];
211             currConnections = minConns;
212             this.maxConns = maxConns;
213             this.dbDriver = dbDriver;
214             this.dbServer = dbServer;
215             this.dbLogin = dbLogin;
216             this.dbPassword = dbPassword;
217
218             maxConnMSec = (int) (maxConnTime * 86400000.0); //86400 sec/day
219
if (maxConnMSec < 30000) { // Recycle no less than 30 seconds.
220
maxConnMSec = 30000;
221             }
222
223             // Write the pid file (used to clean up dead/broken connection)
224

225             log.info("Starting ConnectionPool:");
226             log.info("dbDriver = " + dbDriver);
227             log.info("dbServer = " + dbServer);
228             log.info("dbLogin = " + dbLogin);
229             log.info("minconnections = " + minConns);
230             log.info("maxconnections = " + maxConns);
231             log.info("Total refresh interval = " + maxConnTime + " days");
232             log.info("-----------------------------------------");
233
234             // Initialize the pool of connections with the mininum connections:
235
// Problems creating connections may be caused during reboot when the
236
// servlet is started before the database is ready. Handle this
237
// by waiting and trying again. The loop allows 5 minutes for
238
// db reboot.
239
boolean connectionsSucceeded = false;
240             int dbLoop = 20;
241
242             try {
243                 for (int i = 1; i < dbLoop; i++) {
244                     try {
245                         for (int j = 0; j < currConnections; j++) {
246                             createConn(j);
247                         }
248                         connectionsSucceeded = true;
249                         break;
250                     } catch (SQLException e) {
251                         log.warn(
252                             "--->Attempt ("
253                                 + String.valueOf(i)
254                                 + " of "
255                                 + String.valueOf(dbLoop)
256                                 + ") failed to create new connections set at startup: ", e);
257                         log.info(" Will try again in 15 seconds...");
258                         try {
259                             Thread.sleep(15000);
260                         } catch (InterruptedException JavaDoc e1) {
261                         }
262                     }
263                 }
264                 if (!connectionsSucceeded) { // All attempts at connecting to db exhausted
265
log.warn("\r\nAll attempts at connecting to Database exhausted");
266                     throw new IOException JavaDoc();
267                 }
268             } catch (Exception JavaDoc e) {
269                 log.error("",e);
270                 throw new IOException JavaDoc();
271             }
272
273             // Fire up the background housekeeping thread
274

275             runner = new Thread JavaDoc(this);
276             runner.start();
277
278         } //End ConnectionPool()
279

280         /**
281          * Housekeeping thread. Runs in the background with low CPU overhead.
282          * Connections are checked for warnings and closure and are periodically
283          * restarted.
284          * This thread is a catchall for corrupted
285          * connections and prevents the buildup of open cursors. (Open cursors
286          * result when the application fails to close a Statement).
287          * This method acts as fault tolerance for bad connection/statement programming.
288          */

289         public void run() {
290             boolean forever = true;
291             Statement stmt = null;
292             String JavaDoc currCatalog = null;
293
294             while (forever) {
295                 
296                 // Get any Warnings on connections and print to event file
297
for (int i = 0; i < currConnections; i++) {
298                     try {
299                         currSQLWarning = connPool[i].getWarnings();
300                         if (currSQLWarning != null) {
301                             log.warn("Warnings on connection " + String.valueOf(i) + " " + currSQLWarning);
302                             connPool[i].clearWarnings();
303                         }
304                     } catch (SQLException e) {
305                         log.info("Cannot access Warnings: " + e);
306                     }
307                 }
308
309                 for (int i = 0; i < currConnections; i++) { // Do for each connection
310
long age = System.currentTimeMillis() - connCreateDate[i];
311
312                     synchronized (connStatus) {
313                         if (connStatus[i] > 0) { // In use, catch it next time!
314
continue;
315                         }
316                         connStatus[i] = 2; // Take offline (2 indicates housekeeping lock)
317
}
318
319                     try { // Test the connection with createStatement call
320
if (age > maxConnMSec) { // Force a reset at the max conn time
321
throw new SQLException();
322                         }
323
324                         stmt = connPool[i].createStatement();
325                         connStatus[i] = 0; // Connection is O.K.
326
//log.println("Connection confirmed for conn = " +
327
// String.valueOf(i));
328

329                         // Some DBs return an object even if DB is shut down
330
if (connPool[i].isClosed()) {
331                             throw new SQLException();
332                         }
333                         // Connection has a problem, restart it
334
} catch (SQLException e) {
335                         try {
336                             log.info(
337                                 new Date JavaDoc().toString() + " ***** Recycling connection " + String.valueOf(i) + ":");
338
339                             connPool[i].close();
340                             createConn(i);
341                         } catch (SQLException e1) {
342                             log.error("Failed: " , e1);
343                             connStatus[i] = 0; // Can't open, try again next time
344
}
345                     } finally {
346                         try {
347                             if (stmt != null) {
348                                 stmt.close();
349                             }
350                         } catch (SQLException e1) {
351                         };
352                     }
353                 }
354
355                 try {
356                     Thread.sleep(20000);
357                 } // Wait 20 seconds for next cycle
358
catch (InterruptedException JavaDoc e) {
359                     // Returning from the run method sets the internal
360
// flag referenced by Thread.isAlive() to false.
361
// This is required because we don't use stop() to
362
// shutdown this thread.
363
return;
364                 }
365             }
366         } // End run
367

368         /**
369          * This method hands out the connections in round-robin order.
370          * This prevents a faulty connection from locking
371          * up an application entirely. A browser 'refresh' will
372          * get the next connection while the faulty
373          * connection is cleaned up by the housekeeping thread.
374          *
375          * If the min number of threads are ever exhausted, new
376          * threads are added up the the max thread count.
377          * Finally, if all threads are in use, this method waits
378          * 2 seconds and tries again, up to ten times. After that, it
379          * returns a null.
380          */

381         public Connection getConnection() {
382
383             Connection conn = null;
384
385             if (available) {
386                 boolean gotOne = false;
387
388                 for (int outerloop = 1; outerloop <= 10; outerloop++) {
389
390                     try {
391                         int loop = 0;
392                         int roundRobin = connLast + 1;
393                         if (roundRobin >= currConnections)
394                             roundRobin = 0;
395
396                         do {
397                             synchronized (connStatus) {
398                                 if ((connStatus[roundRobin] < 1) && (!connPool[roundRobin].isClosed())) {
399                                     conn = connPool[roundRobin];
400                                     connStatus[roundRobin] = 1;
401                                     connLockTime[roundRobin] = System.currentTimeMillis();
402                                     connLast = roundRobin;
403                                     gotOne = true;
404                                     break;
405                                 } else {
406                                     loop++;
407                                     roundRobin++;
408                                     if (roundRobin >= currConnections)
409                                         roundRobin = 0;
410                                 }
411                             }
412                         } while ((gotOne == false) && (loop < currConnections));
413                     } catch (SQLException e1) {
414                     }
415
416                     if (gotOne) {
417                         break;
418                     } else {
419                         synchronized (this) { // Add new connections to the pool
420
if (currConnections < maxConns) {
421                                 try {
422                                     createConn(currConnections);
423                                     currConnections++;
424                                 } catch (SQLException e) {
425                                     log.error("Unable to create new connection: " , e);
426                                 }
427                             }
428                         }
429
430                         try {
431                             Thread.sleep(2000);
432                         } catch (InterruptedException JavaDoc e) {
433                         }
434                         log.info(
435                             "-----> Connections Exhausted! Will wait and try "
436                                 + "again in loop "
437                                 + String.valueOf(outerloop));
438                     }
439                 } // End of try 10 times loop
440

441             } else {
442                 log.error("Unsuccessful getConnection() request during destroy()");
443             } // End if(available)
444

445             return conn;
446         }
447
448         /**
449          * Returns the local JDBC ID for a connection.
450          */

451         public int idOfConnection(Connection conn) {
452             int match;
453             String JavaDoc tag;
454
455             try {
456                 tag = conn.toString();
457             } catch (NullPointerException JavaDoc e1) {
458                 tag = "none";
459             }
460
461             match = -1;
462
463             for (int i = 0; i < currConnections; i++) {
464                 if (connID[i].equals(tag)) {
465                     match = i;
466                     break;
467                 }
468             }
469             return match;
470         }
471
472         /**
473          * Frees a connection. Replaces connection back into the main pool for
474          * reuse.
475          */

476         public String JavaDoc freeConnection(Connection conn) {
477             String JavaDoc res = "";
478
479             int thisconn = idOfConnection(conn);
480             if (thisconn >= 0) {
481                 connStatus[thisconn] = 0;
482                 res = "freed " + conn.toString();
483                 //log.println("Freed connection " + String.valueOf(thisconn) +
484
// " normal exit: ");
485
} else {
486                 log.warn("----> Could not free connection!!!");
487             }
488
489             return res;
490         }
491
492         /**
493          * Returns the age of a connection -- the time since it was handed out to
494          * an application.
495          */

496         public long getAge(Connection conn) { // Returns the age of the connection in millisec.
497
int thisconn = idOfConnection(conn);
498             return System.currentTimeMillis() - connLockTime[thisconn];
499         }
500
501         private void createConn(int i) throws SQLException {
502             Date JavaDoc now = new Date JavaDoc();
503             try {
504                 Class.forName(dbDriver);
505                 connPool[i] = DriverManager.getConnection(dbServer, dbLogin, dbPassword);
506                 connStatus[i] = 0;
507                 connID[i] = connPool[i].toString();
508                 connLockTime[i] = 0;
509                 connCreateDate[i] = now.getTime();
510
511                 log.info(
512                     now.toString() + " Opening connection " + String.valueOf(i) + " " + connPool[i].toString() + ":");
513             } catch (ClassNotFoundException JavaDoc e2) {
514                 log.error("",e2);
515                 throw new SQLException(e2.getMessage());
516             }
517         }
518
519         /**
520          * Shuts down the housekeeping thread and closes all connections
521          * in the pool. Call this method from the destroy() method of the servlet.
522          */

523
524         /**
525          * Multi-phase shutdown. having following sequence:
526          * <OL>
527          * <LI><code>getConnection()</code> will refuse to return connections.
528          * <LI>The housekeeping thread is shut down.<br>
529          * Up to the time of <code>millis</code> milliseconds after shutdown of
530          * the housekeeping thread, <code>freeConnection()</code> can still be
531          * called to return used connections.
532          * <LI>After <code>millis</code> milliseconds after the shutdown of the
533          * housekeeping thread, all connections in the pool are closed.
534          * <LI>If any connections were in use while being closed then a
535          * <code>SQLException</code> is thrown.
536          * <LI>The log is closed.
537          * </OL><br>
538          * Call this method from a servlet destroy() method.
539          *
540          * @param millis the time to wait in milliseconds.
541          * @exception SQLException if connections were in use after
542          * <code>millis</code>.
543          */

544         public void destroy(int millis) throws SQLException {
545
546             // Checking for invalid negative arguments is not necessary,
547
// Thread.join() does this already in runner.join().
548

549             // Stop issuing connections
550
available = false;
551
552             // Shut down the background housekeeping thread
553
runner.interrupt();
554
555             // Wait until the housekeeping thread has died.
556
try {
557                 runner.join(millis);
558             } catch (InterruptedException JavaDoc e) {
559             } // ignore
560

561             // The housekeeping thread could still be running
562
// (e.g. if millis is too small). This case is ignored.
563
// At worst, this method will throw an exception with the
564
// clear indication that the timeout was too short.
565

566             long startTime = System.currentTimeMillis();
567
568             // Wait for freeConnection() to return any connections
569
// that are still used at this time.
570
int useCount;
571             while ((useCount = getUseCount()) > 0 && System.currentTimeMillis() - startTime <= millis) {
572                 try {
573                     Thread.sleep(500);
574                 } catch (InterruptedException JavaDoc e) {
575                 } // ignore
576
}
577
578             // Close all connections, whether safe or not
579
for (int i = 0; i < currConnections; i++) {
580                 try {
581                     connPool[i].close();
582                 } catch (SQLException e1) {
583                     log.warn("Cannot close connections on Destroy");
584                 }
585             }
586
587             if (useCount > 0) {
588                 //bt-test successful
589
String JavaDoc msg =
590                     "Unsafe shutdown: Had to close " + useCount + " active DB connections after " + millis + "ms";
591                 log.warn(msg);
592                 
593                 // Throwing following Exception is essential because servlet authors
594
// are likely to have their own error logging requirements.
595
throw new SQLException(msg);
596             }
597
598
599         } //End destroy()
600

601         /**
602          * Less safe shutdown. Uses default timeout value.
603          * This method simply calls the <code>destroy()</code> method
604          * with a <code>millis</code>
605          * value of 10000 (10 seconds) and ignores <code>SQLException</code>
606          * thrown by that method.
607          * @see #destroy(int)
608          */

609         public void destroy() {
610             try {
611                 destroy(10000);
612             } catch (SQLException e) {
613             }
614         }
615
616         /**
617          * Returns the number of connections in use.
618          */

619         // This method could be reduced to return a counter that is
620
// maintained by all methods that update connStatus.
621
// However, it is more efficient to do it this way because:
622
// Updating the counter would put an additional burden on the most
623
// frequently used methods; in comparison, this method is
624
// rarely used (although essential).
625
public int getUseCount() {
626             int useCount = 0;
627             synchronized (connStatus) {
628                 for (int i = 0; i < currConnections; i++) {
629                     if (connStatus[i] > 0) { // In use
630
useCount++;
631                     }
632                 }
633             }
634             return useCount;
635         } //End getUseCount()
636

637         /**
638          * Returns the number of connections in the dynamic pool.
639          */

640         public int getSize() {
641             return currConnections;
642         } //End getSize()
643

644     } // End class
645

646     /**
647      * An implementation of the Connection interface that wraps an underlying
648      * Connection object. It releases the connection back to a connection pool
649      * when Connection.close() is called.
650      */

651     public class ConnectionWrapper implements Connection {
652
653         private Connection connection;
654         private ConnectionPool connectionPool;
655
656         public ConnectionWrapper(Connection connection, ConnectionPool connectionPool) {
657             this.connection = connection;
658             this.connectionPool = connectionPool;
659         }
660
661         /**
662          * Instead of closing the underlying connection, we simply release
663          * it back into the pool.
664          */

665         public void close() throws SQLException {
666             connectionPool.freeConnection(this.connection);
667             //Release object references. Any further method calls on the
668
//connection will fail.
669
connection = null;
670             connectionPool = null;
671         }
672
673         public String JavaDoc toString() {
674             if (connection != null) {
675                 return connection.toString();
676             } else {
677                 return "connection wrapper";
678             }
679         }
680
681         public Statement createStatement() throws SQLException {
682             return connection.createStatement();
683         }
684
685         public PreparedStatement prepareStatement(String JavaDoc sql) throws SQLException {
686             return connection.prepareStatement(sql);
687         }
688
689         public CallableStatement prepareCall(String JavaDoc sql) throws SQLException {
690             return connection.prepareCall(sql);
691         }
692
693         public String JavaDoc nativeSQL(String JavaDoc sql) throws SQLException {
694             return connection.nativeSQL(sql);
695         }
696
697         public void setAutoCommit(boolean autoCommit) throws SQLException {
698             connection.setAutoCommit(autoCommit);
699         }
700
701         public boolean getAutoCommit() throws SQLException {
702             return connection.getAutoCommit();
703         }
704
705         public void commit() throws SQLException {
706             connection.commit();
707         }
708
709         public void rollback() throws SQLException {
710             connection.rollback();
711         }
712
713         public boolean isClosed() throws SQLException {
714             return connection.isClosed();
715         }
716
717         public DatabaseMetaData getMetaData() throws SQLException {
718             return connection.getMetaData();
719         }
720
721         public void setReadOnly(boolean readOnly) throws SQLException {
722             connection.setReadOnly(readOnly);
723         }
724
725         public boolean isReadOnly() throws SQLException {
726             return connection.isReadOnly();
727         }
728
729         public void setCatalog(String JavaDoc catalog) throws SQLException {
730             connection.setCatalog(catalog);
731         }
732
733         public String JavaDoc getCatalog() throws SQLException {
734             return connection.getCatalog();
735         }
736
737         public void setTransactionIsolation(int level) throws SQLException {
738             connection.setTransactionIsolation(level);
739         }
740
741         public int getTransactionIsolation() throws SQLException {
742             return connection.getTransactionIsolation();
743         }
744
745         public SQLWarning getWarnings() throws SQLException {
746             return connection.getWarnings();
747         }
748
749         public void clearWarnings() throws SQLException {
750             connection.clearWarnings();
751         }
752
753         public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
754             return connection.createStatement(resultSetType, resultSetConcurrency);
755         }
756
757         public PreparedStatement prepareStatement(String JavaDoc sql, int resultSetType, int resultSetConcurrency)
758             throws SQLException {
759             return connection.prepareStatement(sql, resultSetType, resultSetConcurrency);
760         }
761
762         public CallableStatement prepareCall(String JavaDoc sql, int resultSetType, int resultSetConcurrency)
763             throws SQLException {
764             return connection.prepareCall(sql, resultSetType, resultSetConcurrency);
765         }
766
767         public Map JavaDoc getTypeMap() throws SQLException {
768             return connection.getTypeMap();
769         }
770
771         public void setTypeMap(Map JavaDoc map) throws SQLException {
772             connection.setTypeMap(map);
773         }
774         //------------------------------------------------------ajout dlaurent
775

776         //comment below to compile with a jdk 1.3
777
/**
778          * @see java.sql.Connection#createStatement(int, int, int)
779          */

780         public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
781             throws SQLException {
782             return connection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
783         }
784
785         /**
786          * @see java.sql.Connection#getHoldability()
787          */

788         public int getHoldability() throws SQLException {
789             return connection.getHoldability();
790         }
791
792         /**
793          * @see java.sql.Connection#prepareCall(String, int, int, int)
794          */

795         public CallableStatement prepareCall(
796             String JavaDoc sql,
797             int resultSetType,
798             int resultSetConcurrency,
799             int resultSetHoldability)
800             throws SQLException {
801             return connection.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
802         }
803
804         /**
805          * @see java.sql.Connection#prepareStatement(String, int, int, int)
806          */

807         public PreparedStatement prepareStatement(
808             String JavaDoc sql,
809             int resultSetType,
810             int resultSetConcurrency,
811             int resultSetHoldability)
812             throws SQLException {
813             return connection.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
814         }
815
816         /**
817          * @see java.sql.Connection#prepareStatement(String, int)
818          */

819         public PreparedStatement prepareStatement(String JavaDoc sql, int autoGeneratedKeys) throws SQLException {
820             return connection.prepareStatement(sql, autoGeneratedKeys);
821         }
822
823         /**
824          * @see java.sql.Connection#prepareStatement(String, int[])
825          */

826         public PreparedStatement prepareStatement(String JavaDoc sql, int[] columnIndexes) throws SQLException {
827             return connection.prepareStatement(sql, columnIndexes);
828         }
829
830         /**
831          * @see java.sql.Connection#prepareStatement(String, String[])
832          */

833         public PreparedStatement prepareStatement(String JavaDoc sql, String JavaDoc[] columnNames) throws SQLException {
834             return connection.prepareStatement(sql, columnNames);
835         }
836
837         /**
838          * @see java.sql.Connection#releaseSavepoint(Savepoint)
839          */

840         public void releaseSavepoint(Savepoint savepoint) throws SQLException {
841             connection.releaseSavepoint(savepoint);
842         }
843
844         /**
845          * @see java.sql.Connection#rollback(Savepoint)
846          */

847         public void rollback(Savepoint savepoint) throws SQLException {
848             connection.rollback(savepoint);
849         }
850
851         /**
852          * @see java.sql.Connection#setHoldability(int)
853          */

854         public void setHoldability(int holdability) throws SQLException {
855             connection.setHoldability(holdability);
856         }
857
858         /**
859          * @see java.sql.Connection#setSavepoint()
860          */

861         public Savepoint setSavepoint() throws SQLException {
862             return connection.setSavepoint();
863         }
864
865         /**
866          * @see java.sql.Connection#setSavepoint(String)
867          */

868         public Savepoint setSavepoint(String JavaDoc name) throws SQLException {
869             return connection.setSavepoint(name);
870         }
871
872     }
873 }
874
Popular Tags