jdk/src/share/classes/javax/sql/DataSource.java
author ohair
Wed, 26 May 2010 20:28:04 -0700
changeset 5551 327690766109
parent 5506 202f599c92aa
child 15278 e081d3f73b75
permissions -rw-r--r--
6956202: Fix a few missed rebranding issues, please contact lines etc. Reviewed-by: jjg, darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.sql;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.sql.Connection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.sql.SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.sql.Wrapper;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>A factory for connections to the physical data source that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <code>DataSource</code> object represents.  An alternative to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <code>DriverManager</code> facility, a <code>DataSource</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * is the preferred means of getting a connection. An object that implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * the <code>DataSource</code> interface will typically be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * registered with a naming service based on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Java<sup><font size=-2>TM</font></sup> Naming and Directory (JNDI) API.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * The <code>DataSource</code> interface is implemented by a driver vendor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * There are three types of implementations:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *   <LI>Basic implementation -- produces a standard <code>Connection</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *       object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *   <LI>Connection pooling implementation -- produces a <code>Connection</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *       object that will automatically participate in connection pooling.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *       implementation works with a middle-tier connection pooling manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *   <LI>Distributed transaction implementation -- produces a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *       <code>Connection</code> object that may be used for distributed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *       transactions and almost always participates in connection pooling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *       This implementation works with a middle-tier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *       transaction manager and almost always with a connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *       pooling manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * </OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * A <code>DataSource</code> object has properties that can be modified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * when necessary.  For example, if the data source is moved to a different
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * server, the property for the server can be changed.  The benefit is that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * because the data source's properties can be changed, any code accessing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * that data source does not need to be changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * A driver that is accessed via a <code>DataSource</code> object does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * register itself with the <code>DriverManager</code>.  Rather, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <code>DataSource</code> object is retrieved though a lookup operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * and then used to create a <code>Connection</code> object.  With a basic
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * implementation, the connection obtained through a <code>DataSource</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * object is identical to a connection obtained through the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <code>DriverManager</code> facility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
public interface DataSource  extends CommonDataSource,Wrapper {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
   * <p>Attempts to establish a connection with the data source that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
   * this <code>DataSource</code> object represents.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
   * @return  a connection to the data source
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
   * @exception SQLException if a database access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
  Connection getConnection() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
   * <p>Attempts to establish a connection with the data source that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
   * this <code>DataSource</code> object represents.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
   * @param username the database user on whose behalf the connection is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
   *  being made
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
   * @param password the user's password
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
   * @return  a connection to the data source
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
   * @exception SQLException if a database access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
   * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
  Connection getConnection(String username, String password)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
}