KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mysql > jdbc > jdbc2 > optional > MysqlConnectionPoolDataSource


1 /*
2    Copyright (C) 2002 MySQL AB
3    
4       This program is free software; you can redistribute it and/or modify
5       it under the terms of the GNU General Public License as published by
6       the Free Software Foundation; either version 2 of the License, or
7       (at your option) any later version.
8    
9       This program is distributed in the hope that it will be useful,
10       but WITHOUT ANY WARRANTY; without even the implied warranty of
11       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12       GNU General Public License for more details.
13    
14       You should have received a copy of the GNU General Public License
15       along with this program; if not, write to the Free Software
16       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17       
18  */

19 package com.mysql.jdbc.jdbc2.optional;
20
21 import java.sql.Connection JavaDoc;
22 import java.sql.SQLException JavaDoc;
23
24 import javax.sql.ConnectionPoolDataSource JavaDoc;
25 import javax.sql.PooledConnection JavaDoc;
26
27
28 /**
29  * This class is used to obtain a physical connection and instantiate and return
30  * a MysqlPooledConnection. J2EE application servers map client calls to
31  * dataSource.getConnection to this class based upon mapping set within deployment
32  * descriptor. This class extends MysqlDataSource.
33  *
34  * @see javax.sql.PooledConnection
35  * @see javax.sql.ConnectionPoolDataSource
36  * @see org.gjt.mm.mysql.MysqlDataSource
37  * @author Todd Wolff <todd.wolff_at_prodigy.net>
38  */

39 public class MysqlConnectionPoolDataSource
40     extends MysqlDataSource
41     implements ConnectionPoolDataSource JavaDoc {
42
43     //~ Methods ...............................................................
44

45     /**
46      * Returns a pooled connection.
47      *
48      * @exception SQLException if an error occurs
49      * @return a PooledConnection
50      */

51     public synchronized PooledConnection JavaDoc getPooledConnection()
52                                                       throws SQLException JavaDoc {
53
54         Connection JavaDoc connection = getConnection();
55         MysqlPooledConnection mysqlPooledConnection = new MysqlPooledConnection(
56                                                               connection);
57
58         return mysqlPooledConnection;
59     }
60
61     /**
62      * This method is invoked by the container. Obtains physical connection using
63      * mySql.Driver class and returns a mysqlPooledConnection object.
64      *
65      * @param s user name
66      * @param s1 password
67      * @exception SQLException if an error occurs
68      * @return a PooledConnection
69      */

70     public synchronized PooledConnection JavaDoc getPooledConnection(String JavaDoc s,
71                                                              String JavaDoc s1)
72                                                       throws SQLException JavaDoc {
73
74         Connection JavaDoc connection = getConnection(s, s1);
75         MysqlPooledConnection mysqlPooledConnection = new MysqlPooledConnection(
76                                                               connection);
77
78         return mysqlPooledConnection;
79     }
80 }
Popular Tags