33ADBA is Asynchronous Database Access, a non-blocking database access api that
44Oracle is proposing as a Java standard. ADBA was announced at
55[ JavaOne 2016] ( https://static.rainfocus.com/oracle/oow16/sess/1461693351182001EmRq/ppt/CONF1578%2020160916.pdf )
6- and presented again at [ JavaOne 2017] ( http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf ) .
7- The ADBA source is available for download from the [ OpenJDK sandbox] ( http://hg.openjdk.java.net/jdk/sandbox/file/9d3b0eb749a9/src/jdk.incubator.adba )
8- as part of the OpenJDK project and the JavaDoc is available [ here] ( http://cr.openjdk.java.net/~lancea/8188051/apidoc/jdk.incubator.adba-summary.html ) .
6+ and presented again at
7+ [ JavaOne 2017] ( http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf ) .
8+ The ADBA source is available for download from the
9+ [ OpenJDK sandbox] ( http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes )
10+ as part of the OpenJDK project and the JavaDoc is available
11+ [ here] ( http://cr.openjdk.java.net/~lancea/8188051/apidoc/jdk.incubator.adba-summary.html ) .
912You can get involved in the ADBA specification effort by following the
1013[ JDBC Expert Group mailing list] ( http://mail.openjdk.java.net/pipermail/jdbc-spec-discuss/ ) .
1114
@@ -18,7 +21,7 @@ JDBC driver.
1821
1922AoJ implements only a small part of ADBA, but it is enough to write interesting
2023code. It provides partial implementations of ``` DataSourceFactory ``` , ``` DataSource ``` ,
21- ``` Connection ``` , ``` OperationGroup ``` , ``` RowOperation ``` , ``` CountOperation ``` ,
24+ ``` Session ``` , ``` OperationGroup ``` , ``` RowOperation ``` , ``` CountOperation ``` ,
2225``` Transaction ``` and others. These implementations are not complete but there is
2326enough there to write interesting database programs. The code that is there is
2427untested, but it does work to some extent. The saving grace is that you can
@@ -36,15 +39,8 @@ better to get it to the community as soon as we could. We hope that you agree.
3639## Building AoJ
3740
3841AoJ and ADBA require JDK 9 or later. Download ADBA from the
39- [ OpenJDK sandbox] ( http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes ) . It does not have any dependencies outside of Java SE.
40-
41- For building the API modules:
42- ```
43- $ mkdir -p mods/jdk.incubator.adba
44- $ javac -d mods/jdk.incubator.adba/ $(find jdk.incubator.adba -name "*.java")
45- $ jar --create --file=mlib/jdk.incubator.adba.jar --module-version=1.0 -C mods/jdk.incubator.adba/ .
46- ````
47- Download AoJ from
42+ [ OpenJDK sandbox] ( http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes ) .
43+ It does not have any dependencies outside of Java SE 9. Download AoJ from
4844[ GitHub] ( https://github.com/oracle/oracle-db-examples/tree/master/java/AoJ ) . Both
4945are modularized so be sure to include the module-info.java files. AoJ depends on
5046ADBA. The AoJ sample file depends on JUnit which is included with most IDEs but is
@@ -59,7 +55,7 @@ driver. The sample file uses the scott/tiger schema available
5955
6056Start the database and load ``` scott.sql ``` . Edit ``` com.oracle.adbaoverjdbc.test.FirstLight.java ```
6157and set the constant ``` URL ``` to an appropriate value. AoJ will pass this value
62- to ```java.sql.DriverManager.getConnection ```. If you are using a database other
58+ to ``` java.sql.DriverManager.getSession ``` . If you are using a database other
6359than Oracle you should change the value of the constant ``` TRIVIAL ``` to some
6460very trivial ``` SELECT ``` query.
6561
@@ -68,34 +64,36 @@ very trivial ```SELECT``` query.
6864The following test case should give you some idea of what AoJ can do. It should
6965run with any JDBC driver connecting to a database with the scott schema. This is
7066the last test in ``` com.oracle.adbaoverjdbc.test.FirstLight.java ``` . For an
71- introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf).
67+ introduction to ADBA see the
68+ [ JavaOne 2017 presentation] ( http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf ) .
7269
7370
74- ```public void transactionSample() {
71+ ```
72+ public void readme(String url, String user, String password) {
7573 // get the AoJ DataSourceFactory
76- DataSourceFactory factory = DataSourceFactory.forName ("com.oracle.adbaoverjdbc.DataSourceFactory");
77- // get a DataSource and a Connection
74+ DataSourceFactory factory = DataSourceFactory.newFactory ("com.oracle.adbaoverjdbc.DataSourceFactory");
75+ // get a DataSource and a Session
7876 try (DataSource ds = factory.builder()
79- .url(URL )
80- .username(“scott" )
81- .password(“tiger" )
77+ .url(url )
78+ .username(user )
79+ .password(password )
8280 .build();
83- Connection conn = ds.getConnection (t -> System.out.println("ERROR: " + t.getMessage()))) {
84- // get a Transaction
85- Transaction trans = conn.transaction ();
81+ Session conn = ds.getSession (t -> System.out.println("ERROR: " + t.getMessage()))) {
82+ // get a TransactionCompletion
83+ TransactionCompletion trans = conn.transactionCompletion ();
8684 // select the EMPNO of CLARK
8785 CompletionStage<Integer> idF = conn.<Integer>rowOperation("select empno, ename from emp where ename = ? for update")
8886 .set("1", "CLARK", AdbaType.VARCHAR)
8987 .collect(Collector.of(
9088 () -> new int[1],
91- (a, r) -> {a[0] = r.get ("empno", Integer.class); },
89+ (a, r) -> {a[0] = r.at ("empno").get( Integer.class); },
9290 (l, r) -> null,
9391 a -> a[0])
9492 )
9593 .submit()
9694 .getCompletionStage();
9795 // update CLARK to work in department 50
98- conn.<Long>countOperation ("update emp set deptno = ? where empno = ?")
96+ conn.<Long>rowCountOperation ("update emp set deptno = ? where empno = ?")
9997 .set("1", 50, AdbaType.INTEGER)
10098 .set("2", idF, AdbaType.INTEGER)
10199 .apply(c -> {
@@ -114,17 +112,15 @@ introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/t
114112 // wait for the async tasks to complete before exiting
115113 ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES);
116114 }
117- ```
118-
119- The following new sample code have been added: HellowWorld.java and NewEmptyJUnitTest.java.
115+ ```
120116
121117## AoJ Design Spec in 100 words or less
122118
123119The methods called by the user thread create a network
124- (i.e., [ DAG] ( https://en.wikipedia.org/wiki/Directed_acyclic_graph ) ) of
120+ ([ DAG] ( https://en.wikipedia.org/wiki/Directed_acyclic_graph ) ) of
125121``` CompletableFuture ``` s. These ``` CompleteableFuture ``` s asynchronously execute
126122the synchronous JDBC calls and the result processing code provided by the user
127123code. By default AoJ uses ``` ForkJoinPool.commonPool() ``` to execute
128124``` CompletableFuture ``` s but the user code can provide another ``` Executor ``` .
129- When the ``` Connection ``` is submitted the root of the ``` CompleteableFuture ```
125+ When the ``` Session ``` is submitted the root of the ``` CompleteableFuture ```
130126network is completed triggering execution of the rest of the network.
0 commit comments