1 | /* |
2 | |
3 | Derby - Class org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource |
4 | |
5 | Copyright 2001, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.jdbc; |
22 | |
23 | import java.sql.SQLException; |
24 | |
25 | /* -- New jdbc 20 extension types --- */ |
26 | import javax.sql.ConnectionPoolDataSource; |
27 | import javax.sql.PooledConnection; |
28 | |
29 | /** |
30 | EmbeddedConnectionPoolDataSource is Derby's ConnectionPoolDataSource |
31 | implementation for the JDBC3.0 and JDBC2.0 environments. |
32 | |
33 | |
34 | <P>A ConnectionPoolDataSource is a factory for PooledConnection |
35 | objects. An object that implements this interface will typically be |
36 | registered with a JNDI service. |
37 | <P> |
38 | EmbeddedConnectionPoolDataSource automatically supports the correct JDBC specification version |
39 | for the Java Virtual Machine's environment. |
40 | <UL> |
41 | <LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0 |
42 | <LI> JDBC 2.0 - Java 2 - JDK 1.2,1.3 |
43 | </UL> |
44 | |
45 | <P>EmbeddedConnectionPoolDataSource is serializable and referenceable. |
46 | |
47 | <P>See EmbeddedDataSource for DataSource properties. |
48 | |
49 | */ |
50 | public class EmbeddedConnectionPoolDataSource extends EmbeddedDataSource |
51 | implements javax.sql.ConnectionPoolDataSource |
52 | { |
53 | |
54 | private static final long serialVersionUID = 7852784308039674160L; |
55 | |
56 | /** |
57 | No-arg constructor. |
58 | */ |
59 | public EmbeddedConnectionPoolDataSource() { |
60 | super(); |
61 | } |
62 | |
63 | /* |
64 | * ConnectionPoolDataSource methods |
65 | */ |
66 | |
67 | /** |
68 | Attempt to establish a database connection. |
69 | |
70 | @return a Connection to the database |
71 | |
72 | @exception SQLException if a database-access error occurs. |
73 | */ |
74 | public final PooledConnection getPooledConnection() throws SQLException { |
75 | return createPooledConnection (getUser(), getPassword(), false); |
76 | } |
77 | |
78 | /** |
79 | Attempt to establish a database connection. |
80 | |
81 | @param username the database user on whose behalf the Connection is being made |
82 | @param password the user's password |
83 | |
84 | @return a Connection to the database |
85 | |
86 | @exception SQLException if a database-access error occurs. |
87 | */ |
88 | public final PooledConnection getPooledConnection(String username, |
89 | String password) |
90 | throws SQLException |
91 | { |
92 | return createPooledConnection (username, password, true); |
93 | } |
94 | |
95 | /** |
96 | * create and returns EmbedPooledConnection. |
97 | */ |
98 | protected PooledConnection createPooledConnection (String user, |
99 | String password, boolean requestPAssword) throws SQLException { |
100 | return new EmbedPooledConnection(this, user, password, true); |
101 | } |
102 | } |
103 | |
104 | |
105 | |
106 | |
107 | |