Source code: com/mysql/jdbc/jdbc2/optional/MysqlConnectionPoolDataSource.java
1 /*
2 Copyright (C) 2002-2004 MySQL AB
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of version 2 of the GNU General Public License as
6 published by the Free Software Foundation.
7
8
9 There are special exceptions to the terms and conditions of the GPL
10 as it is applied to this software. View the full text of the
11 exception exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
12 software distribution.
13
14 This program 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. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23 */
24 package com.mysql.jdbc.jdbc2.optional;
25
26 import java.sql.Connection;
27 import java.sql.SQLException;
28
29 import javax.sql.ConnectionPoolDataSource;
30 import javax.sql.PooledConnection;
31
32
33 /**
34 * This class is used to obtain a physical connection and instantiate and return
35 * a MysqlPooledConnection. J2EE application servers map client calls to
36 * dataSource.getConnection to this class based upon mapping set within deployment
37 * descriptor. This class extends MysqlDataSource.
38 *
39 * @see javax.sql.PooledConnection
40 * @see javax.sql.ConnectionPoolDataSource
41 * @see org.gjt.mm.mysql.MysqlDataSource
42 * @author Todd Wolff <todd.wolff_at_prodigy.net>
43 */
44 public class MysqlConnectionPoolDataSource
45 extends MysqlDataSource
46 implements ConnectionPoolDataSource {
47
48 //~ Methods ...............................................................
49
50 /**
51 * Returns a pooled connection.
52 *
53 * @exception SQLException if an error occurs
54 * @return a PooledConnection
55 */
56 public synchronized PooledConnection getPooledConnection()
57 throws SQLException {
58
59 Connection connection = getConnection();
60 MysqlPooledConnection mysqlPooledConnection = new MysqlPooledConnection(
61 connection);
62
63 return mysqlPooledConnection;
64 }
65
66 /**
67 * This method is invoked by the container. Obtains physical connection using
68 * mySql.Driver class and returns a mysqlPooledConnection object.
69 *
70 * @param s user name
71 * @param s1 password
72 * @exception SQLException if an error occurs
73 * @return a PooledConnection
74 */
75 public synchronized PooledConnection getPooledConnection(String s,
76 String s1)
77 throws SQLException {
78
79 Connection connection = getConnection(s, s1);
80 MysqlPooledConnection mysqlPooledConnection = new MysqlPooledConnection(
81 connection);
82
83 return mysqlPooledConnection;
84 }
85 }