Skip to content

Commit 320d8ce

Browse files
Adding sample with descriptor set as ConnectionFactoryOptions.HOST
1 parent b105fe6 commit 320d8ce

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

sample/src/main/java/oracle/r2dbc/samples/DescriptorURL.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,24 @@ public static void main(String[] args) {
7070
.concatWith(Mono.from(connection.close()).cast(String.class)))
7171
.toStream()
7272
.forEach(System.out::println);
73+
74+
// A descriptor may also be specified as the value of
75+
// ConnectionFactoryOptions.HOST
76+
Mono.from(ConnectionFactories.get(ConnectionFactoryOptions.builder()
77+
.option(ConnectionFactoryOptions.DRIVER, "oracle")
78+
.option(ConnectionFactoryOptions.HOST, DESCRIPTOR)
79+
.option(ConnectionFactoryOptions.USER, USER)
80+
.option(ConnectionFactoryOptions.PASSWORD, PASSWORD)
81+
.build())
82+
.create())
83+
.flatMapMany(connection ->
84+
Mono.from(connection.createStatement(
85+
"SELECT 'Connected with TNS descriptor' FROM sys.dual")
86+
.execute())
87+
.flatMapMany(result ->
88+
result.map((row, metadata) -> row.get(0, String.class)))
89+
.concatWith(Mono.from(connection.close()).cast(String.class)))
90+
.toStream()
91+
.forEach(System.out::println);
7392
}
7493
}

0 commit comments

Comments
 (0)