@@ -57,8 +57,7 @@ public void gettingStarted() {
57
57
// A simple query
58
58
client
59
59
.query ("SELECT * FROM users WHERE id='julien'" )
60
- .execute ()
61
- .onComplete (ar -> {
60
+ .execute (ar -> {
62
61
if (ar .succeeded ()) {
63
62
RowSet <Row > result = ar .result ();
64
63
System .out .println ("Got " + result .size () + " rows " );
@@ -87,10 +86,9 @@ public void configureFromDataObject(Vertx vertx) {
87
86
// Create the pool from the data object
88
87
DB2Pool pool = DB2Pool .pool (vertx , connectOptions , poolOptions );
89
88
90
- pool .getConnection ()
91
- .onComplete (ar -> {
92
- // Handling your connection
93
- });
89
+ pool .getConnection (ar -> {
90
+ // Handling your connection
91
+ });
94
92
}
95
93
96
94
public void configureFromUri (Vertx vertx ) {
@@ -102,10 +100,9 @@ public void configureFromUri(Vertx vertx) {
102
100
DB2Pool pool = DB2Pool .pool (connectionUri );
103
101
104
102
// Create the connection from the connection URI
105
- DB2Connection .connect (vertx , connectionUri )
106
- .onComplete (res -> {
107
- // Handling your connection
108
- });
103
+ DB2Connection .connect (vertx , connectionUri , res -> {
104
+ // Handling your connection
105
+ });
109
106
}
110
107
111
108
public void connecting01 () {
@@ -262,45 +259,44 @@ public void connectSsl(Vertx vertx) {
262
259
.setPath ("/path/to/keystore.p12" )
263
260
.setPassword ("keystoreSecret" ));
264
261
265
- DB2Connection .connect (vertx , options )
266
- .onComplete (res -> {
267
- if (res .succeeded ()) {
268
- // Connected with SSL
269
- } else {
270
- System .out .println ("Could not connect " + res .cause ());
271
- }
272
- });
262
+ DB2Connection .connect (vertx , options , res -> {
263
+ if (res .succeeded ()) {
264
+ // Connected with SSL
265
+ } else {
266
+ System .out .println ("Could not connect " + res .cause ());
267
+ }
268
+ });
273
269
}
274
270
275
271
public void generatedKeys (SqlClient client ) {
276
272
client
277
273
.preparedQuery ("SELECT color_id FROM FINAL TABLE ( INSERT INTO color (color_name) VALUES (?), (?), (?) )" )
278
- .execute (Tuple .of ("white" , "red" , "blue" ))
279
- .onComplete (ar -> {
280
- if (ar .succeeded ()) {
281
- RowSet <Row > rows = ar .result ();
282
- System .out .println ("Inserted " + rows .rowCount () + " new rows." );
283
- for (Row row : rows ) {
284
- System .out .println ("generated key: " + row .getInteger ("color_id" ));
285
- }
286
- } else {
287
- System .out .println ("Failure: " + ar .cause ().getMessage ());
274
+ .execute (Tuple .of ("white" , "red" , "blue" ), ar -> {
275
+ if (ar .succeeded ()) {
276
+ RowSet <Row > rows = ar .result ();
277
+ System .out .println ("Inserted " + rows .rowCount () + " new rows." );
278
+ for (Row row : rows ) {
279
+ System .out .println ("generated key: " + row .getInteger ("color_id" ));
288
280
}
289
- });
281
+ } else {
282
+ System .out .println ("Failure: " + ar .cause ().getMessage ());
283
+ }
284
+ });
290
285
}
291
286
292
287
public void typeMapping01 (Pool pool ) {
293
288
pool
294
289
.query ("SELECT an_int_column FROM exampleTable" )
295
- .execute ().onSuccess (rowSet -> {
296
- Row row = rowSet .iterator ().next ();
290
+ .execute (ar -> {
291
+ RowSet <Row > rowSet = ar .result ();
292
+ Row row = rowSet .iterator ().next ();
297
293
298
- // Stored as INTEGER column type and represented as java.lang.Integer
299
- Object value = row .getValue (0 );
294
+ // Stored as INTEGER column type and represented as java.lang.Integer
295
+ Object value = row .getValue (0 );
300
296
301
- // Convert to java.lang.Long
302
- Long longValue = row .getLong (0 );
303
- });
297
+ // Convert to java.lang.Long
298
+ Long longValue = row .getLong (0 );
299
+ });
304
300
}
305
301
306
302
public void collector01Example (SqlClient client ) {
@@ -313,18 +309,17 @@ public void collector01Example(SqlClient client) {
313
309
// Run the query with the collector
314
310
client .query ("SELECT * FROM users" )
315
311
.collecting (collector )
316
- .execute ()
317
- .onComplete (ar -> {
318
- if (ar .succeeded ()) {
319
- SqlResult <Map <Long , String >> result = ar .result ();
312
+ .execute (ar -> {
313
+ if (ar .succeeded ()) {
314
+ SqlResult <Map <Long , String >> result = ar .result ();
320
315
321
- // Get the map created by the collector
322
- Map <Long , String > map = result .value ();
323
- System .out .println ("Got " + map );
324
- } else {
325
- System .out .println ("Failure: " + ar .cause ().getMessage ());
326
- }
327
- });
316
+ // Get the map created by the collector
317
+ Map <Long , String > map = result .value ();
318
+ System .out .println ("Got " + map );
319
+ } else {
320
+ System .out .println ("Failure: " + ar .cause ().getMessage ());
321
+ }
322
+ });
328
323
}
329
324
330
325
public void collector02Example (SqlClient client ) {
@@ -336,11 +331,7 @@ public void collector02Example(SqlClient client) {
336
331
);
337
332
338
333
// Run the query with the collector
339
- client
340
- .query ("SELECT * FROM users" )
341
- .collecting (collector )
342
- .execute ()
343
- .onComplete (ar -> {
334
+ client .query ("SELECT * FROM users" ).collecting (collector ).execute (ar -> {
344
335
if (ar .succeeded ()) {
345
336
SqlResult <String > result = ar .result ();
346
337
@@ -362,38 +353,36 @@ enum Days {
362
353
* Using an enum as a string value in the Row and Tuple methods.
363
354
*/
364
355
public void enumStringValues (SqlClient client ) {
365
- client .preparedQuery ("SELECT day_name FROM FINAL TABLE ( INSERT INTO days (day_name) VALUES (?), (?), (?) )" )
366
- .execute (Tuple .of (Days .FRIDAY , Days .SATURDAY , Days .SUNDAY ))
367
- .onComplete (ar -> {
368
- if (ar .succeeded ()) {
369
- RowSet <Row > rows = ar .result ();
370
- System .out .println ("Inserted " + rows .rowCount () + " new rows" );
371
- for (Row row : rows ) {
372
- System .out .println ("Day: " + row .get (Days .class , "day_name" ));
373
- }
374
- } else {
375
- System .out .println ("Failure: " + ar .cause ().getMessage ());
376
- }
377
- });
356
+ client .preparedQuery ("SELECT day_name FROM FINAL TABLE ( INSERT INTO days (day_name) VALUES (?), (?), (?) )" )
357
+ .execute (Tuple .of (Days .FRIDAY , Days .SATURDAY , Days .SUNDAY ), ar -> {
358
+ if (ar .succeeded ()) {
359
+ RowSet <Row > rows = ar .result ();
360
+ System .out .println ("Inserted " + rows .rowCount () + " new rows" );
361
+ for (Row row : rows ) {
362
+ System .out .println ("Day: " + row .get (Days .class , "day_name" ));
363
+ }
364
+ } else {
365
+ System .out .println ("Failure: " + ar .cause ().getMessage ());
366
+ }
367
+ });
378
368
}
379
369
380
370
/**
381
371
* Using an enum as an int value in the Row and Tuple methods.
382
372
* The row.get() method returns the corresponding enum's name() value at the ordinal position of the integer value retrieved.
383
373
*/
384
374
public void enumIntValues (SqlClient client ) {
385
- client .preparedQuery ("SELECT day_num FROM FINAL TABLE ( INSERT INTO days (day_num) VALUES (?), (?), (?) )" )
386
- .execute (Tuple .of (Days .FRIDAY .ordinal (), Days .SATURDAY .ordinal (), Days .SUNDAY .ordinal ()))
387
- .onComplete (ar -> {
388
- if (ar .succeeded ()) {
389
- RowSet <Row > rows = ar .result ();
390
- System .out .println ("Inserted " + rows .rowCount () + " new rows" );
391
- for (Row row : rows ) {
392
- System .out .println ("Day: " + row .get (Days .class , "day_num" ));
393
- }
394
- } else {
395
- System .out .println ("Failure: " + ar .cause ().getMessage ());
396
- }
375
+ client .preparedQuery ("SELECT day_num FROM FINAL TABLE ( INSERT INTO days (day_num) VALUES (?), (?), (?) )" )
376
+ .execute (Tuple .of (Days .FRIDAY .ordinal (), Days .SATURDAY .ordinal (), Days .SUNDAY .ordinal ()), ar -> {
377
+ if (ar .succeeded ()) {
378
+ RowSet <Row > rows = ar .result ();
379
+ System .out .println ("Inserted " + rows .rowCount () + " new rows" );
380
+ for (Row row : rows ) {
381
+ System .out .println ("Day: " + row .get (Days .class , "day_num" ));
382
+ }
383
+ } else {
384
+ System .out .println ("Failure: " + ar .cause ().getMessage ());
385
+ }
397
386
});
398
387
}
399
388
0 commit comments