use of io.vertx.ext.sql.SQLConnection in project Summer by yale8848.
the class MyVerticle method start.
@Override
public void start() throws Exception {
vertx.eventBus().consumer("user", message -> {
EventMessage eventMessage = (EventMessage) message.body();
eventMessage.success(true);
eventMessage.setMessage("Hello " + eventMessage.getObject());
message.reply(eventMessage);
});
vertx.fileSystem().readFile("dev/dbt.json", bufferAsyncResult -> {
if (bufferAsyncResult.succeeded()) {
JsonObject jsonObject = bufferAsyncResult.result().toJsonObject().getJsonObject("reader");
jdbcReader = JDBCClient.createShared(vertx, jsonObject, "reader");
jdbcReader.getConnection(sqlConnectionAsyncResult -> {
if (sqlConnectionAsyncResult.succeeded()) {
LOGGER.info("+++++ db success");
SQLConnection sqlConnection = sqlConnectionAsyncResult.result();
sqlConnection.query(new SummerSQL().SELECT("*").FROM("db_test.tb_test").toString(), resultSetAsyncResult -> {
if (resultSetAsyncResult.succeeded()) {
List<DBTest> tests = ResultSetMapper.create().camelName().mapperList(resultSetAsyncResult.result(), DBTest.class);
}
sqlConnection.close();
});
} else {
}
});
}
});
}
Aggregations