KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  
3    Derby - Class org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource40
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 package org.apache.derby.jdbc;
22
23 import java.sql.SQLException JavaDoc;
24 import javax.sql.ConnectionPoolDataSource JavaDoc;
25 import javax.sql.DataSource JavaDoc;
26 import javax.sql.PooledConnection JavaDoc;
27
28 import org.apache.derby.impl.jdbc.Util;
29 import org.apache.derby.iapi.reference.SQLState;
30
31 /**
32     EmbeddedConnectionPoolDataSource40 is Derby's ConnectionPoolDataSource
33     implementation for the JDBC4.0 environment.
34     
35
36     <P>A ConnectionPoolDataSource is a factory for PooledConnection
37     objects. An object that implements this interface will typically be
38     registered with a JNDI service.
39     <P>
40     EmbeddedConnectionPoolDataSource40 supports the JDBC 4.0 specification
41     for the J2SE 6.0 Java Virtual Machine environment. Use
42     EmbeddedConnectionPoolDataSource if your application runs in the
43     following environments:
44     <UL>
45     <LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0
46     <LI> JDBC 2.0 - Java 2 - JDK 1.2,1.3
47     </UL>
48
49     <P>EmbeddedConnectionPoolDataSource40 is serializable and referenceable.
50
51     <P>See EmbeddedDataSource40 for DataSource properties.
52
53  */

54 public class EmbeddedConnectionPoolDataSource40
55                                 extends EmbeddedConnectionPoolDataSource
56                                 implements ConnectionPoolDataSource JavaDoc {
57     
58     /**
59      * Returns false unless <code>interfaces</code> is implemented
60      *
61      * @param interfaces a Class defining an interface.
62      * @return true if this implements the interface or
63      * directly or indirectly wraps an object
64      * that does.
65      * @throws java.sql.SQLException if an error occurs while determining
66      * whether this is a wrapper for an object
67      * with the given interface.
68      */

69     public boolean isWrapperFor(Class JavaDoc<?> interfaces) throws SQLException JavaDoc {
70         return interfaces.isInstance(this);
71     }
72     
73     /**
74      * Returns <code>this</code> if this class implements the interface
75      *
76      * @param interfaces a Class defining an interface
77      * @return an object that implements the interface
78      * @throws java.sql.SQLExption if no object if found that implements the
79      * interface
80      */

81     public <T> T unwrap(java.lang.Class JavaDoc<T> interfaces)
82                             throws SQLException JavaDoc{
83         //Derby does not implement non-standard methods on
84
//JDBC objects
85
//hence return this if this class implements the interface
86
//or throw an SQLException
87
try {
88             return interfaces.cast(this);
89         } catch (ClassCastException JavaDoc cce) {
90             throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
91                     interfaces);
92         }
93     }
94
95     /**
96      * create and returns EmbedPooledConnection.
97      */

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