< prev index next >

jdk/src/java.sql/share/classes/javax/sql/XAConnectionBuilder.java

Print this page




  35  * default values by the {@code XAConnectionBuilder}.
  36  * <p>The following example illustrates the use of {@code XAConnectionBuilder}
  37  * to create a {@link XAConnection}:
  38  *
  39  * <pre>{@code
  40  *     DataSource ds = new MyDataSource();
  41  *     ShardingKey superShardingKey = ds.createShardingKeyBuilder()
  42  *                           .subkey("EASTERN_REGION", JDBCType.VARCHAR)
  43  *                           .build();
  44  *     ShardingKey shardingKey = ds.createShardingKeyBuilder()
  45  *                           .subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
  46  *                           .build();
  47  *     XAConnection con = ds.createXAConnectionBuilder()
  48  *                       .user("rafa")
  49  *                       .password("tennis")
  50  *                       .setShardingKey(shardingKey)
  51  *                       .setSuperShardingKey(superShardingKey)
  52  *                       .build();
  53  * }</pre>
  54  *
  55  * @since 1.9
  56  *
  57  */
  58 public interface XAConnectionBuilder  {
  59 
  60     /**
  61      * Specifies the username to be used when creating a connection
  62      *
  63      * @param username the database user on whose behalf the connection is being
  64      * made
  65      * @return the same {@code XAConnectionBuilder} instance
  66      */
  67     XAConnectionBuilder user(String username);
  68 
  69     /**
  70      * Specifies the password to be used when creating a connection
  71      *
  72      * @param password the password to use for this connection. May be {@code null}
  73      * @return the same {@code XAConnectionBuilder} instance
  74      */
  75     XAConnectionBuilder password(String password);




  35  * default values by the {@code XAConnectionBuilder}.
  36  * <p>The following example illustrates the use of {@code XAConnectionBuilder}
  37  * to create a {@link XAConnection}:
  38  *
  39  * <pre>{@code
  40  *     DataSource ds = new MyDataSource();
  41  *     ShardingKey superShardingKey = ds.createShardingKeyBuilder()
  42  *                           .subkey("EASTERN_REGION", JDBCType.VARCHAR)
  43  *                           .build();
  44  *     ShardingKey shardingKey = ds.createShardingKeyBuilder()
  45  *                           .subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
  46  *                           .build();
  47  *     XAConnection con = ds.createXAConnectionBuilder()
  48  *                       .user("rafa")
  49  *                       .password("tennis")
  50  *                       .setShardingKey(shardingKey)
  51  *                       .setSuperShardingKey(superShardingKey)
  52  *                       .build();
  53  * }</pre>
  54  *
  55  * @since 9
  56  *
  57  */
  58 public interface XAConnectionBuilder  {
  59 
  60     /**
  61      * Specifies the username to be used when creating a connection
  62      *
  63      * @param username the database user on whose behalf the connection is being
  64      * made
  65      * @return the same {@code XAConnectionBuilder} instance
  66      */
  67     XAConnectionBuilder user(String username);
  68 
  69     /**
  70      * Specifies the password to be used when creating a connection
  71      *
  72      * @param password the password to use for this connection. May be {@code null}
  73      * @return the same {@code XAConnectionBuilder} instance
  74      */
  75     XAConnectionBuilder password(String password);


< prev index next >