src/java.sql/share/classes/javax/sql/CommonDataSource.java
author naoto
Thu, 31 Jan 2019 12:43:59 -0800
changeset 53614 125012edb689
parent 47216 71c04702a3d5
permissions -rw-r--r--
8217892: Clarify the support for the new Japanese era in java.time.chrono.JapaneseEra Reviewed-by: chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
35277
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
     2
 * Copyright (c) 2005, 2016, 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.SQLException;
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    29
import java.sql.SQLFeatureNotSupportedException;
35277
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
    30
import java.sql.ShardingKeyBuilder;
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    31
import java.util.logging.Logger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * Interface that defines the methods which are common between <code>DataSource</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <code>XADataSource</code> and <code>ConnectionPoolDataSource</code>.
20880
1b610151b316 8026812: doclint clean up for java.sql and javax.sql
lancea
parents: 18564
diff changeset
    36
 *
24968
3308660aa3f2 8046389: Add missing @since tag under javax.sql.**
henryjen
parents: 20880
diff changeset
    37
 * @since 1.6
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
public interface CommonDataSource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    41
    /**
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    42
     * <p>Retrieves the log writer for this <code>DataSource</code>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    43
     * object.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    44
     *
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    45
     * <p>The log writer is a character output stream to which all logging
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    46
     * and tracing messages for this data source will be
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    47
     * printed.  This includes messages printed by the methods of this
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    48
     * object, messages printed by methods of other objects manufactured
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    49
     * by this object, and so on.  Messages printed to a data source
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    50
     * specific log writer are not printed to the log writer associated
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    51
     * with the <code>java.sql.DriverManager</code> class.  When a
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    52
     * <code>DataSource</code> object is
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    53
     * created, the log writer is initially null; in other words, the
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    54
     * default is for logging to be disabled.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    55
     *
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    56
     * @return the log writer for this data source or null if
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    57
     *        logging is disabled
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    58
     * @exception java.sql.SQLException if a database access error occurs
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    59
     * @see #setLogWriter
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    60
     */
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    61
    java.io.PrintWriter getLogWriter() throws SQLException;
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    62
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    63
    /**
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    64
     * <p>Sets the log writer for this <code>DataSource</code>
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    65
     * object to the given <code>java.io.PrintWriter</code> object.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    66
     *
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    67
     * <p>The log writer is a character output stream to which all logging
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    68
     * and tracing messages for this data source will be
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    69
     * printed.  This includes messages printed by the methods of this
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    70
     * object, messages printed by methods of other objects manufactured
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    71
     * by this object, and so on.  Messages printed to a data source-
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    72
     * specific log writer are not printed to the log writer associated
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    73
     * with the <code>java.sql.DriverManager</code> class. When a
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    74
     * <code>DataSource</code> object is created the log writer is
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    75
     * initially null; in other words, the default is for logging to be
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    76
     * disabled.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    77
     *
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    78
     * @param out the new log writer; to disable logging, set to null
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    79
     * @exception SQLException if a database access error occurs
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    80
     * @see #getLogWriter
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    81
     */
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    82
    void setLogWriter(java.io.PrintWriter out) throws SQLException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    84
    /**
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    85
     * <p>Sets the maximum time in seconds that this data source will wait
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    86
     * while attempting to connect to a database.  A value of zero
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    87
     * specifies that the timeout is the default system timeout
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    88
     * if there is one; otherwise, it specifies that there is no timeout.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    89
     * When a <code>DataSource</code> object is created, the login timeout is
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    90
     * initially zero.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    91
     *
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    92
     * @param seconds the data source login time limit
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    93
     * @exception SQLException if a database access error occurs.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    94
     * @see #getLoginTimeout
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    95
     */
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    96
    void setLoginTimeout(int seconds) throws SQLException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    98
    /**
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
    99
     * Gets the maximum time in seconds that this data source can wait
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   100
     * while attempting to connect to a database.  A value of zero
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   101
     * means that the timeout is the default system timeout
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   102
     * if there is one; otherwise, it means that there is no timeout.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   103
     * When a <code>DataSource</code> object is created, the login timeout is
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   104
     * initially zero.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   105
     *
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   106
     * @return the data source login time limit
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   107
     * @exception SQLException if a database access error occurs.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   108
     * @see #setLoginTimeout
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   109
     */
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   110
    int getLoginTimeout() throws SQLException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   112
    //------------------------- JDBC 4.1 -----------------------------------
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   114
    /**
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   115
     * Return the parent Logger of all the Loggers used by this data source. This
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   116
     * should be the Logger farthest from the root Logger that is
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   117
     * still an ancestor of all of the Loggers used by this data source. Configuring
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   118
     * this Logger will affect all of the log messages generated by the data source.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   119
     * In the worst case, this may be the root Logger.
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   120
     *
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   121
     * @return the parent Logger for this data source
18564
f9db68ff2cbb 8017471: Fix JDBC -Xdoclint public errors
lancea
parents: 6540
diff changeset
   122
     * @throws SQLFeatureNotSupportedException if the data source does not use
f9db68ff2cbb 8017471: Fix JDBC -Xdoclint public errors
lancea
parents: 6540
diff changeset
   123
     * {@code java.util.logging}
6540
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   124
     * @since 1.7
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   125
     */
a4ae668f6125 6589685: JDBC 4.1 updates
lancea
parents: 5506
diff changeset
   126
    public Logger getParentLogger() throws SQLFeatureNotSupportedException;
35277
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   127
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   128
    //------------------------- JDBC 4.3 -----------------------------------
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   129
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   130
    /**
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   131
     * Creates a new {@code ShardingKeyBuilder} instance
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   132
     * @implSpec
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   133
     * The default implementation will throw a {@code SQLFeatureNotSupportedException}.
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   134
     * @return The ShardingKeyBuilder instance that was created
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   135
     * @throws SQLException if an error occurs creating the builder
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   136
     * @throws SQLFeatureNotSupportedException if the driver does not support this method
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   137
     * @since 9
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   138
     * @see ShardingKeyBuilder
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   139
    */
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   140
    default ShardingKeyBuilder createShardingKeyBuilder() throws SQLException {
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   141
        throw new SQLFeatureNotSupportedException("createShardingKeyBuilder not implemented");
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents: 25859
diff changeset
   142
  };
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
}