Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

19 descriptor sample #21

Merged
merged 3 commits into from
Mar 31, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Adding sample with descriptor set as ConnectionFactoryOptions.HOST
  • Loading branch information
Michael-A-McMahon committed Mar 30, 2021
commit 320d8ce3ecc1854107f57565756c7ba2efbe2950
19 changes: 19 additions & 0 deletions sample/src/main/java/oracle/r2dbc/samples/DescriptorURL.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,24 @@ public static void main(String[] args) {
.concatWith(Mono.from(connection.close()).cast(String.class)))
.toStream()
.forEach(System.out::println);

// A descriptor may also be specified as the value of
// ConnectionFactoryOptions.HOST
Mono.from(ConnectionFactories.get(ConnectionFactoryOptions.builder()
.option(ConnectionFactoryOptions.DRIVER, "oracle")
.option(ConnectionFactoryOptions.HOST, DESCRIPTOR)
.option(ConnectionFactoryOptions.USER, USER)
.option(ConnectionFactoryOptions.PASSWORD, PASSWORD)
.build())
.create())
.flatMapMany(connection ->
Mono.from(connection.createStatement(
"SELECT 'Connected with TNS descriptor' FROM sys.dual")
.execute())
.flatMapMany(result ->
result.map((row, metadata) -> row.get(0, String.class)))
.concatWith(Mono.from(connection.close()).cast(String.class)))
.toStream()
.forEach(System.out::println);
}
}