Skip to content

Commit d5c4493

Browse files
Merge branch 'main' of https://github.com/oracle/oracle-r2dbc into array-types
2 parents d9306d7 + 4b68ec7 commit d5c4493

22 files changed

+1989
-677
lines changed

.github/workflows/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ echo "HOST=localhost" >> src/test/resources/config.properties
8181
echo "PORT=1521" >> src/test/resources/config.properties
8282
echo "USER=test" >> src/test/resources/config.properties
8383
echo "PASSWORD=test" >> src/test/resources/config.properties
84-
echo "CONNECT_TIMEOUT=60" >> src/test/resources/config.properties
85-
echo "SQL_TIMEOUT=60" >> src/test/resources/config.properties
84+
echo "CONNECT_TIMEOUT=120" >> src/test/resources/config.properties
85+
echo "SQL_TIMEOUT=120" >> src/test/resources/config.properties
8686
mvn clean compile test

README.md

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,22 +191,22 @@ are supported by Oracle R2DBC:
191191
- `HOST`
192192
- `PORT`
193193
- `DATABASE`
194+
- The database option is interpreted as the
195+
[service name](https://docs.oracle.com/en/database/oracle/oracle-database/21/netag/identifying-and-accessing-database.html#GUID-153861C1-16AD-41EC-A179-074146B722E6)
196+
of an Oracle Database instance. _System Identifiers (SID) are not recognized_.
194197
- `USER`
195198
- `PASSWORD`
196199
- `SSL`
197200
- `CONNECT_TIMEOUT`
198201
- `STATEMENT_TIMEOUT`.
199-
200-
> Oracle R2DBC interprets the `DATABASE` option as the
201-
> [service name](https://docs.oracle.com/en/database/oracle/oracle-database/21/netag/identifying-and-accessing-database.html#GUID-153861C1-16AD-41EC-A179-074146B722E6)
202-
> of an Oracle Database instance. _System Identifiers (SID) are not recognized_.
202+
- `PROTOCOL`
203+
- (For inclusion in the next release) Accepted protocol values are "tcps", "ldap", and "ldaps"
203204

204205
#### Support for Extended R2DBC Options
205206
Oracle R2DBC extends the standard set of R2DBC options to offer functionality
206207
that is specific to Oracle Database and the Oracle JDBC Driver. Extended options
207208
are declared in the
208-
[OracleR2dbcOptions](src/main/java/oracle/r2dbc/OracleR2dbcOptions.java)
209-
class.
209+
[OracleR2dbcOptions](src/main/java/oracle/r2dbc/OracleR2dbcOptions.java) class.
210210

211211
#### Configuring an Oracle Net Descriptor
212212
The `oracle.r2dbc.OracleR2dbcOptions.DESCRIPTOR` option may be used to configure
@@ -234,6 +234,22 @@ located:
234234
r2dbc:oracle://?oracle.r2dbc.descriptor=myAlias&TNS_ADMIN=/path/to/tnsnames/
235235
```
236236

237+
#### (For inclusion in the next release) Configuring an LDAP URL
238+
Use `ldap` or `ldaps` as the URL protocol to have an Oracle Net Descriptor
239+
retrieved from an LDAP server:
240+
```
241+
r2dbc:oracle:ldap://ldap.example.com:7777/sales,cn=OracleContext,dc=com
242+
r2dbc:oracle:ldaps://ldap.example.com:7778/sales,cn=OracleContext,dc=com
243+
```
244+
Use a space separated list of LDAP URIs for fail over and load balancing:
245+
```
246+
r2dbc:oracle:ldap://ldap1.example.com:7777/sales,cn=OracleContext,dc=com%20ldap://ldap2.example.com:7777/sales,cn=OracleContext,dc=com%20ldap://ldap3.example.com:7777/sales,cn=OracleContext,dc=com
247+
```
248+
> Space characters in a URL must be percent encoded as `%20`
249+
250+
An LDAP server request will **block a thread for network I/O** when Oracle R2DBC
251+
creates a new connection.
252+
237253
#### Configuring a java.util.concurrent.Executor
238254
The `oracle.r2dbc.OracleR2dbcOptions.EXECUTOR` option configures a
239255
`java.util.concurrent.Executor` for executing asynchronous callbacks. The
@@ -508,12 +524,13 @@ for the out parameters is emitted last, after the `Result` for each cursor.
508524
Oracle R2DBC supports type mappings between Java and SQL for non-standard data
509525
types of Oracle Database.
510526

511-
| Oracle SQL Type | Java Type |
512-
|---------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
513-
| [JSON](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Data-Types.html#GUID-E441F541-BA31-4E8C-B7B4-D2FB8C42D0DF) | `javax.json.JsonObject` or `oracle.sql.json.OracleJsonObject` |
514-
| [DATE](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Data-Types.html#GUID-5405B652-C30E-4F4F-9D33-9A4CB2110F1B) | `java.time.LocalDateTime` |
515-
| [INTERVAL DAY TO SECOND](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Data-Types.html#GUID-B03DD036-66F8-4BD3-AF26-6D4433EBEC1C) | `java.time.Duration` |
516-
| [INTERVAL YEAR TO MONTH](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Data-Types.html#GUID-ED59E1B3-BA8D-4711-B5C8-B0199C676A95) | `java.time.Period` |
527+
| Oracle SQL Type | Java Type |
528+
|---------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
529+
| [JSON](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Data-Types.html#GUID-E441F541-BA31-4E8C-B7B4-D2FB8C42D0DF) | `javax.json.JsonObject` or `oracle.sql.json.OracleJsonObject` |
530+
| [DATE](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Data-Types.html#GUID-5405B652-C30E-4F4F-9D33-9A4CB2110F1B) | `java.time.LocalDateTime` |
531+
| [INTERVAL DAY TO SECOND](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Data-Types.html#GUID-B03DD036-66F8-4BD3-AF26-6D4433EBEC1C) | `java.time.Duration` |
532+
| [INTERVAL YEAR TO MONTH](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Data-Types.html#GUID-ED59E1B3-BA8D-4711-B5C8-B0199C676A95) | `java.time.Period` |
533+
| [SYS_REFCURSOR](https://docs.oracle.com/en/database/oracle/oracle-database/21/lnpls/static-sql.html#GUID-470A7A99-888A-46C2-BDAF-D4710E650F27) | `io.r2dbc.spi.Result` |
517534
> Unlike the standard SQL type named "DATE", the Oracle Database type named
518535
> "DATE" stores values for year, month, day, hour, minute, and second. The
519536
> standard SQL type only stores year, month, and day. LocalDateTime objects are able
@@ -600,6 +617,36 @@ Publisher<Integer[]> arrayMapExample(Result result) {
600617
return result.map(readable -> readable.get("arrayValue", Integer[].class));
601618
}
602619
```
620+
621+
### REF Cursor
622+
Use the `oracle.r2dbc.OracleR2dbcTypes.REF_CURSOR` type to bind `SYS_REFCURSOR` out
623+
parameters:
624+
```java
625+
Publisher<Result> executeProcedure(Connection connection) {
626+
connection.createStatement(
627+
"BEGIN example_procedure(:cursor_parameter); END;")
628+
.bind("cursor_parameter", Parameters.out(OracleR2dbcTypes.REF_CURSOR))
629+
.execute()
630+
}
631+
```
632+
A `SYS_REFCURSOR` out parameter can be mapped to an `io.r2dbc.spi.Result`:
633+
```java
634+
Publisher<Result> mapOutParametersResult(Result outParametersResult) {
635+
return outParametersResult.map(outParameters ->
636+
outParameters.get("cursor_parameter", Result.class));
637+
}
638+
```
639+
The rows of a `SYS_REFCURSOR` may be consumed from the `Result` it is
640+
mapped to:
641+
```java
642+
Publisher<ExampleObject> mapRefCursorRows(Result refCursorResult) {
643+
return refCursorResult.map(row ->
644+
new ExampleObject(
645+
row.get("id_column", Long.class),
646+
row.get("value_column", String.class)));
647+
}
648+
```
649+
603650
## Secure Programming Guidelines
604651
The following security related guidelines should be adhered to when programming
605652
with the Oracle R2DBC Driver.

pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@
8787
<arg>-Xlint:-processing</arg>
8888
<arg>-Xlint:-serial</arg>
8989
</compilerArgs>
90+
<!-- LDAP URL tests require the java.naming module -->
91+
<!-- Maven seems to ignore the forceJavacCompilerUse.
92+
This results in an error when passing the addModules option to
93+
the javax.tools API. For this reason, Oracle R2DBC's module-info is
94+
declaring a depency on the java.naming module.
95+
TODO: Figure out how to make maven compile tests correctly, and
96+
remove the java.naming depenency from Oracle R2DBC.
97+
<fork>true</fork>
98+
<forceJavacCompilerUse>true</forceJavacCompilerUse>
99+
<testCompilerArgument>- -add-modules java.naming</testCompilerArgument>
100+
-->
90101
<showWarnings>true</showWarnings>
91102
<release>${java.version}</release>
92103
</configuration>
@@ -150,6 +161,7 @@
150161
<artifactId>maven-surefire-plugin</artifactId>
151162
<version>3.0.0-M5</version>
152163
<configuration>
164+
<!-- Include tests in the oracle.r2dbc.test package -->
153165
<includes>
154166
<include>**/*Test.java</include>
155167
<include>**/*TestKit.java</include>
@@ -278,7 +290,6 @@
278290
<artifactId>reactor-test</artifactId>
279291
<scope>test</scope>
280292
</dependency>
281-
282293
</dependencies>
283294

284295
<profiles>

src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
with oracle.r2dbc.impl.OracleConnectionFactoryProviderImpl;
3131

3232
requires java.sql;
33+
requires java.naming;
3334
requires com.oracle.database.jdbc;
3435
requires reactor.core;
3536
requires transitive org.reactivestreams;

0 commit comments

Comments
 (0)