本文整理汇总了Java中io.vertx.ext.sql.SQLConnection.execute方法的典型用法代码示例。如果您正苦于以下问题:Java SQLConnection.execute方法的具体用法?Java SQLConnection.execute怎么用?Java SQLConnection.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.sql.SQLConnection
的用法示例。
在下文中一共展示了SQLConnection.execute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testQueryTimeout
import io.vertx.ext.sql.SQLConnection; //导入方法依赖的package包/类
@Test
public void testQueryTimeout() {
String sql = "{call NAP(1) + NAP(1) + NAP(1) + NAP(1) + NAP(1)}";
final SQLConnection conn = connection();
conn.execute("CREATE FUNCTION NAP() returns INT PARAMETER STYLE JAVA reads sql data language JAVA EXTERNAL NAME 'io.vertx.ext.jdbc.Functions.nap'", onSuccess(res -> {
conn.setQueryTimeout(1).call(sql, onFailure(resultSet -> {
assertNotNull(resultSet);
// assertEquals(1, resultSet.getResults().size());
// // we expect a String since UUID will be converted with the fallback mode
// assertNotNull(resultSet.getResults().get(0).getString(0));
testComplete();
}));
}));
await();
}
示例2: testMultiSelect
import io.vertx.ext.sql.SQLConnection; //导入方法依赖的package包/类
@Test
public void testMultiSelect() {
String sql = "{ call MS() }";
final SQLConnection conn = connection();
conn.execute("CREATE PROCEDURE MS() PARAMETER STYLE JAVA LANGUAGE JAVA READS SQL DATA DYNAMIC RESULT SETS 2 EXTERNAL NAME 'io.vertx.ext.jdbc.Functions.multiSelect'", onSuccess(res -> {
conn.call(sql, onSuccess(resultSet -> {
assertNotNull(resultSet);
assertNotNull(resultSet.getNext());
testComplete();
}));
}));
await();
}
示例3: execute
import io.vertx.ext.sql.SQLConnection; //导入方法依赖的package包/类
private void execute(SQLConnection conn, String sql, Handler<Void> done) {
conn.execute(sql, res -> {
if (res.failed()) {
throw new RuntimeException(res.cause());
}
done.handle(null);
});
}
示例4: example6
import io.vertx.ext.sql.SQLConnection; //导入方法依赖的package包/类
public void example6(SQLConnection connection) {
String sql = "CREATE TABLE PEOPLE (ID int generated by default as identity (start with 1 increment by 1) not null," +
"FNAME varchar(255), LNAME varchar(255), SHOE_SIZE int);";
connection.execute(sql, execute -> {
if (execute.succeeded()) {
System.out.println("Table created !");
} else {
// Failed!
}
});
}
示例5: setupSimpleTable
import io.vertx.ext.sql.SQLConnection; //导入方法依赖的package包/类
private void setupSimpleTable(SQLConnection conn, Handler<AsyncResult<Void>> handler) {
conn.execute("BEGIN",
ar -> conn.execute("DROP TABLE IF EXISTS test_table",
ar2 -> conn.execute(CREATE_TABLE_STATEMENT,
ar3 -> conn.update("INSERT INTO test_table (id, name) VALUES " + Data.get(),
ar4 -> conn.execute("COMMIT", handler)))));
}
示例6: setupTestTable
import io.vertx.ext.sql.SQLConnection; //导入方法依赖的package包/类
private void setupTestTable(SQLConnection conn, Supplier<String> idNameValuesSupplier, Handler<AsyncResult<Void>> handler) {
conn.execute("BEGIN",
ar -> conn.execute("DROP TABLE IF EXISTS test_table",
ar2 -> conn.execute(CREATE_TABLE_STATEMENT,
ar3 -> conn.update("INSERT INTO test_table (id, name) VALUES " + idNameValuesSupplier.get(),
ar4 -> conn.execute("COMMIT", handler)))));
}
示例7: setupAutoIncrementTable
import io.vertx.ext.sql.SQLConnection; //导入方法依赖的package包/类
private void setupAutoIncrementTable(SQLConnection conn, Handler<AsyncResult<Void>> handler) {
conn.execute("BEGIN",
ar -> conn.execute("DROP TABLE IF EXISTS test_table",
ar2 -> conn.execute("CREATE TABLE test_table (id BIGSERIAL, name VARCHAR(255), PRIMARY KEY(id))",
ar3 -> conn.execute("COMMIT", handler::handle))));
}
示例8: setupTableWithUUIDs
import io.vertx.ext.sql.SQLConnection; //导入方法依赖的package包/类
private void setupTableWithUUIDs(SQLConnection conn, Handler<AsyncResult<Void>> handler) {
conn.execute("BEGIN",
ar -> conn.execute("DROP TABLE IF EXISTS test_table",
ar2 -> conn.execute("CREATE TABLE test_table (some_uuid UUID, name VARCHAR(255))",
ar3 -> conn.execute("COMMIT", handler::handle))));
}
示例9: setupAutoIncrementTable
import io.vertx.ext.sql.SQLConnection; //导入方法依赖的package包/类
private void setupAutoIncrementTable(SQLConnection conn, Handler<AsyncResult<Void>> handler) {
conn.execute("BEGIN",
ar -> conn.execute("DROP TABLE IF EXISTS test_table",
ar2 -> conn.execute("CREATE TABLE test_table (id BIGINT AUTO_INCREMENT, name VARCHAR(255), PRIMARY KEY(id))",
ar3 -> conn.execute("COMMIT", handler::handle))));
}