src/java.sql/share/classes/java/sql/Driver.java
author psadhukhan
Fri, 09 Nov 2018 09:29:43 +0530
changeset 52543 3853631e6a07
parent 47216 71c04702a3d5
permissions -rw-r--r--
8213181: Updation of ProblemList.txt for removal of passing swing test Reviewed-by: serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
     2
 * Copyright (c) 1996, 2013, 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 java.sql;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    28
import java.util.logging.Logger;
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    29
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * The interface that every driver class must implement.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * <P>The Java SQL framework allows for multiple database drivers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <P>Each driver should supply a class that implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * the Driver interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <P>The DriverManager will try to load as many drivers as it can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * find and then for any given connection request, it will ask each
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * driver in turn to try to connect to the target URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <P>It is strongly recommended that each Driver class should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * small and standalone so that the Driver class can be loaded and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * queried without bringing in vast quantities of supporting code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <P>When a Driver class is loaded, it should create an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * itself and register it with the DriverManager. This means that a
17199
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 15278
diff changeset
    47
 * user can load and register a driver by calling:
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 15278
diff changeset
    48
 * <p>
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 15278
diff changeset
    49
 * {@code Class.forName("foo.bah.Driver")}
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 15278
diff changeset
    50
 * <p>
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 15278
diff changeset
    51
 * A JDBC driver may create a {@linkplain DriverAction} implementation in order
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 15278
diff changeset
    52
 * to receive notifications when {@linkplain DriverManager#deregisterDriver} has
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 15278
diff changeset
    53
 * been called.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @see DriverManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @see Connection
17199
28853592ce2b 8010416: Add a way for java.sql.Driver to be notified when it is deregistered
lancea
parents: 15278
diff changeset
    56
 * @see DriverAction
44256
12050b22e372 8176721: @since value errors java.sql module
mli
parents: 25859
diff changeset
    57
 * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
public interface Driver {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Attempts to make a database connection to the given URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * The driver should return "null" if it realizes it is the wrong kind
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * of driver to connect to the given URL.  This will be common, as when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * the JDBC driver manager is asked to connect to a given URL it passes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * the URL to each loaded driver in turn.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * <P>The driver should throw an <code>SQLException</code> if it is the right
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * driver to connect to the given URL but has trouble connecting to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
    72
     * <P>The {@code Properties} argument can be used to pass
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * arbitrary string tag/value pairs as connection arguments.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Normally at least "user" and "password" properties should be
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
    75
     * included in the {@code Properties} object.
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
    76
     * <p>
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
    77
     * <B>Note:</B> If a property is specified as part of the {@code url} and
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
    78
     * is also specified in the {@code Properties} object, it is
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
    79
     * implementation-defined as to which value will take precedence. For
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
    80
     * maximum portability, an application should only specify a property once.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @param url the URL of the database to which to connect
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @param info a list of arbitrary string tag/value pairs as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * connection arguments. Normally at least a "user" and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * "password" property should be included.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @return a <code>Connection</code> object that represents a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *         connection to the URL
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
    88
     * @exception SQLException if a database access error occurs or the url is
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
    89
     * {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    Connection connect(String url, java.util.Properties info)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * Retrieves whether the driver thinks that it can open a connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * to the given URL.  Typically drivers will return <code>true</code> if they
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
    97
     * understand the sub-protocol specified in the URL and <code>false</code> if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * they do not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @param url the URL of the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @return <code>true</code> if this driver understands the given URL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *         <code>false</code> otherwise
15278
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
   103
     * @exception SQLException if a database access error occurs or the url is
e081d3f73b75 8005080: JDBC 4.2 Core changes
lancea
parents: 6540
diff changeset
   104
     * {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    boolean acceptsURL(String url) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * Gets information about the possible properties for this driver.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * The <code>getPropertyInfo</code> method is intended to allow a generic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * GUI tool to discover what properties it should prompt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * a human for in order to get
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * enough information to connect to a database.  Note that depending on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * the values the human has supplied so far, additional values may become
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * necessary, so it may be necessary to iterate though several calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * to the <code>getPropertyInfo</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @param url the URL of the database to which to connect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @param info a proposed list of tag/value pairs that will be sent on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *          connect open
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @return an array of <code>DriverPropertyInfo</code> objects describing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *          possible properties.  This array may be an empty array if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *          no properties are required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @exception SQLException if a database access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    DriverPropertyInfo[] getPropertyInfo(String url, java.util.Properties info)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                         throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * Retrieves the driver's major version number. Initially this should be 1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @return this driver's major version number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    int getMajorVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Gets the driver's minor version number. Initially this should be 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @return this driver's minor version number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    int getMinorVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * Reports whether this driver is a genuine JDBC
18564
f9db68ff2cbb 8017471: Fix JDBC -Xdoclint public errors
lancea
parents: 17199
diff changeset
   148
     * Compliant&trade; driver.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * A driver may only report <code>true</code> here if it passes the JDBC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * compliance tests; otherwise it is required to return <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * JDBC compliance requires full support for the JDBC API and full support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * for SQL 92 Entry Level.  It is expected that JDBC compliant drivers will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * be available for all the major commercial databases.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * This method is not intended to encourage the development of non-JDBC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * compliant drivers, but is a recognition of the fact that some vendors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * are interested in using the JDBC API and framework for lightweight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * databases that do not support full database functionality, or for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * special databases such as document information retrieval where a SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * implementation may not be feasible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @return <code>true</code> if this driver is JDBC Compliant; <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *         otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    boolean jdbcCompliant();
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   166
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   167
    //------------------------- JDBC 4.1 -----------------------------------
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   168
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   169
    /**
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   170
     * Return the parent Logger of all the Loggers used by this driver. This
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   171
     * should be the Logger farthest from the root Logger that is
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   172
     * still an ancestor of all of the Loggers used by this driver. Configuring
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   173
     * this Logger will affect all of the log messages generated by the driver.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   174
     * In the worst case, this may be the root Logger.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   175
     *
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   176
     * @return the parent Logger for this driver
18564
f9db68ff2cbb 8017471: Fix JDBC -Xdoclint public errors
lancea
parents: 17199
diff changeset
   177
     * @throws SQLFeatureNotSupportedException if the driver does not use
f9db68ff2cbb 8017471: Fix JDBC -Xdoclint public errors
lancea
parents: 17199
diff changeset
   178
     * {@code java.util.logging}.
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   179
     * @since 1.7
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   180
     */
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   181
    public Logger getParentLogger() throws SQLFeatureNotSupportedException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
}