Closed
Description
The method below prints out "Successful insertion" and "Insertion failed".
Am I missing something or is it a normal behavior?
private void insert(Movie movie, SQLConnection connection, Handler<AsyncResult<Movie>> next) {
String sql = "INSERT INTO Movies (name, release) VALUES (?, ?)";
JsonArray json = new JsonArray().add(movie.getName()).add(movie.getRelease());
connection.updateWithParams(
sql,
json,
(asyncResult) -> {
if (asyncResult.succeeded()) {
System.out.println("Successful insertion");
}
if (asyncResult.failed()) {
System.out.println("Insertion failed");
next.handle(Future.failedFuture(asyncResult.cause()));
return;
}
UpdateResult result = asyncResult.result();
Movie m = new Movie(result.getKeys().getInteger(0), movie.getName(), movie.getRelease());
next.handle(Future.succeededFuture(m));
}
);
}
Metadata
Metadata
Assignees
Labels
No labels