KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > jdbc > DataSource


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.appserv.jdbc;
24
25 import java.sql.Connection JavaDoc;
26 import java.sql.SQLException JavaDoc;
27
28 /**
29  * The <code>javax.sql.DataSource</code> implementation of SunONE application
30  * server will implement this interface. An application program would be able
31  * to use this interface to do the extended functionality exposed by SunONE
32  * application server.
33  * <p>A sample code for getting driver's connection implementation would like
34  * the following.
35  * <pre>
36      InitialContext ic = new InitialContext();
37      com.sun.appserv.DataSource ds = (com.sun.appserv.DataSOurce) ic.lookup("jdbc/PointBase");
38      Connection con = ds.getConnection();
39      Connection drivercon = ds.getConnection(con);
40
41      // Do db operations.
42
43      con.close();
44    </pre>
45  *
46  * @author Binod P.G
47  */

48 public interface DataSource extends javax.sql.DataSource JavaDoc {
49
50     /**
51      * Retrieves the actual SQLConnection from the Connection wrapper
52      * implementation of SunONE application server. If an actual connection is
53      * supplied as argument, then it will be just returned.
54      *
55      * @param con Connection obtained from <code>Datasource.getConnection()</code>
56      * @return <code>java.sql.Connection</code> implementation of the driver.
57      * @throws <code>java.sql.SQLException</code> If connection cannot be obtained.
58      */

59     public Connection JavaDoc getConnection(Connection JavaDoc con) throws SQLException JavaDoc;
60
61     /**
62      * Gets a connection that is not in the scope of any transaction. This
63      * can be used to save performance overhead incurred on enlisting/delisting
64      * each connection got, irrespective of whether its required or not.
65      * Note here that this meethod does not fit in the connector contract
66      * per se.
67      *
68      * @return <code>java.sql.Connection</code>
69      * @throws <code>java.sql.SQLException</code> If connection cannot be obtained
70      */

71     public Connection JavaDoc getNonTxConnection() throws SQLException JavaDoc;
72
73     /**
74      * Gets a connection that is not in the scope of any transaction. This
75      * can be used to save performance overhead incurred on enlisting/delisting
76      * each connection got, irrespective of whether its required or not.
77      * Note here that this meethod does not fit in the connector contract
78      * per se.
79      *
80      * @param user User name for authenticating the connection
81      * @param password Password for authenticating the connection
82      * @return <code>java.sql.Connection</code>
83      * @throws <code>java.sql.SQLException</code> If connection cannot be obtained
84      */

85     public Connection JavaDoc getNonTxConnection( String JavaDoc userName, String JavaDoc password )
86         throws SQLException JavaDoc;
87
88 }
89
Popular Tags