src/java.sql/share/classes/javax/sql/PooledConnectionBuilder.java
author naoto
Thu, 31 Jan 2019 12:43:59 -0800
changeset 53614 125012edb689
parent 47216 71c04702a3d5
child 55448 0f141453b9e0
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:
35277
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
     1
/*
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
     4
 *
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    10
 *
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    15
 * accompanied this code).
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    16
 *
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    20
 *
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    23
 * questions.
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    24
 */
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    25
package javax.sql;
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    26
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    27
import java.sql.SQLException;
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    28
import java.sql.ShardingKey;
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    29
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    30
/**
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    31
 * A builder created from a {@code ConnectionPoolDataSource} object,
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    32
 * used to establish a connection to the database that the
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    33
 * {@code data source} object represents.  The connection
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    34
 * properties that were specified for the {@code data source} are used as the
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    35
 * default values by the {@code PooledConnectionBuilder}.
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    36
 * <p>The following example illustrates the use of {@code PooledConnectionBuilder}
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    37
 * to create a {@link XAConnection}:
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    38
 *
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    39
 * <pre>{@code
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    40
 *     ConnectionPoolDataSource ds = new MyConnectionPoolDataSource();
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    41
 *     ShardingKey superShardingKey = ds.createShardingKeyBuilder()
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    42
 *                           .subkey("EASTERN_REGION", JDBCType.VARCHAR)
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    43
 *                           .build();
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    44
 *     ShardingKey shardingKey = ds.createShardingKeyBuilder()
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    45
 *                           .subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    46
 *                           .build();
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    47
 *     PooledConnection con = ds.createPooledConnectionBuilder()
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    48
 *                       .user("rafa")
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    49
 *                       .password("tennis")
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    50
 *                       .setShardingKey(shardingKey)
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    51
 *                       .setSuperShardingKey(superShardingKey)
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    52
 *                       .build();
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    53
 * }</pre>
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    54
 *
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    55
 * @since 9
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    56
 *
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    57
 */
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    58
public interface PooledConnectionBuilder  {
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    59
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    60
    /**
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    61
     * Specifies the username to be used when creating a connection
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    62
     *
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    63
     * @param username the database user on whose behalf the connection is being
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    64
     * made
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    65
     * @return the same {@code PooledConnectionBuilder} instance
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    66
     */
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    67
    PooledConnectionBuilder user(String username);
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    68
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    69
    /**
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    70
     * Specifies the password to be used when creating a connection
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    71
     *
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    72
     * @param password the password to use for this connection. May be {@code null}
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    73
     * @return the same {@code PooledConnectionBuilder} instance
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    74
     */
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    75
    PooledConnectionBuilder password(String password);
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    76
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    77
    /**
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    78
     * Specifies a {@code shardingKey} to be used when creating a connection
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    79
     *
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    80
     * @param shardingKey the ShardingKey. May be {@code null}
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    81
     * @return the same {@code PooledConnectionBuilder} instance
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    82
     * @see java.sql.ShardingKey
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    83
     * @see java.sql.ShardingKeyBuilder
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    84
     */
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    85
    PooledConnectionBuilder shardingKey(ShardingKey shardingKey);
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    86
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    87
    /**
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    88
     * Specifies a {@code superShardingKey} to be used when creating a connection
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    89
     *
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    90
     * @param superShardingKey the SuperShardingKey. May be {@code null}
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    91
     * @return the same {@code PooledConnectionBuilder} instance
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    92
     * @see java.sql.ShardingKey
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    93
     * @see java.sql.ShardingKeyBuilder
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    94
     */
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    95
    PooledConnectionBuilder superShardingKey(ShardingKey superShardingKey);
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    96
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    97
    /**
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    98
     * Returns an instance of the object defined by this builder.
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
    99
     *
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
   100
     * @return The built object
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
   101
     * @throws java.sql.SQLException If an error occurs building the object
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
   102
     */
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
   103
    PooledConnection build() throws SQLException;
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
   104
eb4794f43d20 8146803: Enhance and update Sharding API
lancea
parents:
diff changeset
   105
}