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