KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > jdbc > EmbeddedConnectionPoolDataSource


1 /*
2
3    Derby - Class org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.jdbc;
23
24 import java.sql.SQLException JavaDoc;
25
26 /* -- New jdbc 20 extension types --- */
27 import javax.sql.ConnectionPoolDataSource JavaDoc;
28 import javax.sql.PooledConnection JavaDoc;
29
30 /**
31     EmbeddedConnectionPoolDataSource is Derby's ConnectionPoolDataSource
32     implementation for the JDBC3.0 and JDBC2.0 environments.
33     
34
35     <P>A ConnectionPoolDataSource is a factory for PooledConnection
36     objects. An object that implements this interface will typically be
37     registered with a JNDI service.
38     <P>
39     EmbeddedConnectionPoolDataSource automatically supports the correct JDBC specification version
40     for the Java Virtual Machine's environment.
41     <UL>
42     <LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0
43     <LI> JDBC 2.0 - Java 2 - JDK 1.2,1.3
44     </UL>
45
46     <P>EmbeddedConnectionPoolDataSource is serializable and referenceable.
47
48     <P>See EmbeddedDataSource for DataSource properties.
49
50  */

51 public class EmbeddedConnectionPoolDataSource extends EmbeddedDataSource
52         implements javax.sql.ConnectionPoolDataSource JavaDoc
53 {
54
55     private static final long serialVersionUID = 7852784308039674160L;
56
57     /**
58         No-arg constructor.
59      */

60     public EmbeddedConnectionPoolDataSource() {
61         super();
62     }
63
64     /*
65      * ConnectionPoolDataSource methods
66      */

67
68     /**
69         Attempt to establish a database connection.
70
71         @return a Connection to the database
72
73         @exception SQLException if a database-access error occurs.
74     */

75     public final PooledConnection JavaDoc getPooledConnection() throws SQLException JavaDoc {
76         return createPooledConnection (getUser(), getPassword(), false);
77     }
78
79     /**
80         Attempt to establish a database connection.
81
82         @param username the database user on whose behalf the Connection is being made
83         @param password the user's password
84
85         @return a Connection to the database
86
87         @exception SQLException if a database-access error occurs.
88     */

89     public final PooledConnection JavaDoc getPooledConnection(String JavaDoc username,
90                                                 String JavaDoc password)
91          throws SQLException JavaDoc
92     {
93         return createPooledConnection (username, password, true);
94     }
95         
96     /**
97      * create and returns EmbedPooledConnection.
98      */

99     protected PooledConnection JavaDoc createPooledConnection (String JavaDoc user,
100             String JavaDoc password, boolean requestPassword) throws SQLException JavaDoc {
101         return new EmbedPooledConnection(this, user, password, requestPassword);
102     }
103 }
104
105
106
107
108
109
Popular Tags