@@ -33,30 +33,41 @@ Here is a quick teaser of how to use R2DBC GaussDB in Java:
3333** URL Connection Factory Discovery**
3434
3535``` java
36- ConnectionFactory connectionFactory = ConnectionFactories . get(" r2dbc:gaussdb://<host>:8000/<database>" );
36+ ConnectionFactory connectionFactory = connectionFactory = ConnectionFactories . get(
37+ " r2dbc:gaussdb://GaussdbExamples:Gaussdb-Examples-123@localhost:8000/postgres" );
3738
3839Publisher<? extends Connection > connectionPublisher = connectionFactory. create();
3940```
4041
4142** Programmatic Connection Factory Discovery**
4243
4344``` java
44- Map<String , String > options = new HashMap<> ();
45-
4645ConnectionFactory connectionFactory = ConnectionFactories . get(ConnectionFactoryOptions . builder()
47- .option(DRIVER , " gaussdb" )
48- .option(HOST , " ..." )
49- .option(PORT , 8000 ) // optional, defaults to 8000
50- .option(USER , " ..." )
51- .option(PASSWORD , " ..." )
52- .option(DATABASE , " ..." ) // optional
53- .option(OPTIONS , options) // optional
54- .build());
46+ .option(ConnectionFactoryOptions . DRIVER , " gaussdb" )
47+ .option(ConnectionFactoryOptions . HOST , " localhost" )
48+ .option(ConnectionFactoryOptions . PORT , 8000 )
49+ .option(ConnectionFactoryOptions . USER , " GaussdbExamples" )
50+ .option(ConnectionFactoryOptions . PASSWORD , " Gaussdb-Examples-123" )
51+ .option(ConnectionFactoryOptions . DATABASE , " postgres" ). build());
5552
5653Publisher<? extends Connection > connectionPublisher = connectionFactory. create();
54+ ```
55+
56+ ** Programmatic Configuration**
57+
58+ ``` java
59+ Map<String , String > options = new HashMap<> ();
60+ GaussDBConnectionFactory gaussDBConnectionFactory = new GaussDBConnectionFactory (
61+ GaussDBConnectionConfiguration . builder()
62+ .host(" localhost" )
63+ .port(8000 )
64+ .username(" GaussdbExamples" )
65+ .password(" Gaussdb-Examples-123" )
66+ .database(" postgres" ) // optional
67+ .options(options) // optional
68+ .build());
5769
58- // Alternative: Creating a Mono using Project Reactor
59- Mono<Connection > connectionMono = Mono . from(connectionFactory. create());
70+ Publisher<? extends Connection > connectionPublisher = connectionFactory. create();
6071```
6172
6273** Supported ConnectionFactory Discovery Options**
@@ -101,21 +112,6 @@ Mono<Connection> connectionMono = Mono.from(connectionFactory.create());
101112| ` tcpKeepAlive ` | Enable/disable TCP KeepAlive. Disabled by default. _ (Optional)_
102113| ` timeZone ` | Configure the session timezone to control conversion of local temporal representations. Defaults to ` TimeZone.getDefault() ` _ (Optional)_
103114
104- ** Programmatic Configuration**
105-
106- ``` java
107- Map<String , String > options = new HashMap<> ();
108- PostgresqlConnectionFactory connectionFactory = new PostgresqlConnectionFactory (PostgresqlConnectionConfiguration . builder()
109- .host(" ..." )
110- .port(8000 ) // optional, defaults to 8000
111- .username(" ..." )
112- .password(" ..." )
113- .database(" ..." ) // optional
114- .options(options) // optional
115- .build());
116-
117- Mono<Connection > mono = connectionFactory. create();
118- ```
119115
120116GaussDB uses index parameters that are prefixed with ` $ ` . The following SQL statement makes use of parameters:
121117
0 commit comments