io.vertx.ext.sql.SQLConnection.setOptions()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中io.vertx.ext.sql.SQLConnection.setOptions()方法的一些代码示例,展示了SQLConnection.setOptions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SQLConnection.setOptions()方法的具体详情如下:
包路径:io.vertx.ext.sql.SQLConnection
类名称:SQLConnection
方法名:setOptions

SQLConnection.setOptions介绍

[英]Sets the desired options to be applied to the current connection when statements are executed. The options are not applied globally but applicable to the current connection. For example changing the transaction isolation level will only affect statements run on this connection and not future or current connections acquired from the connection pool. This method is not async in nature since the apply will only happen at the moment a query is run.
[中]设置执行语句时要应用于当前连接的所需选项。这些选项不会全局应用,但适用于当前连接。例如,更改事务隔离级别只会影响在此连接上运行的语句,而不会影响从连接池获取的未来或当前连接。这个方法本质上不是异步的,因为apply只会在查询运行时发生。

代码示例

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * Sets the desired options to be applied to the current connection when statements are executed.
 *
 * The options are not applied globally but applicable to the current connection. For example changing the transaction
 * isolation level will only affect statements run on this connection and not future or current connections acquired
 * from the connection pool.
 *
 * This method is not async in nature since the apply will only happen at the moment a query is run.
 * @param options the options to modify the unwrapped connection.
 * @return 
 */
public io.vertx.rxjava.ext.sql.SQLConnection setOptions(SQLOptions options) { 
 delegate.setOptions(options);
 return this;
}

代码示例来源:origin: vert-x3/vertx-rx

/**
 * Sets the desired options to be applied to the current connection when statements are executed.
 *
 * The options are not applied globally but applicable to the current connection. For example changing the transaction
 * isolation level will only affect statements run on this connection and not future or current connections acquired
 * from the connection pool.
 *
 * This method is not async in nature since the apply will only happen at the moment a query is run.
 * @param options the options to modify the unwrapped connection.
 * @return 
 */
public io.vertx.rxjava.ext.sql.SQLConnection setOptions(SQLOptions options) { 
 delegate.setOptions(options);
 return this;
}

代码示例来源:origin: io.vertx/vertx-jdbc-client

@Override
public SQLConnection setOptions(SQLOptions options) {
 delegate.setOptions(options);
 return this;
}

代码示例来源:origin: io.vertx/vertx-sql-common

/**
 * Sets a connection wide query timeout.
 *
 * It can be over written at any time and becomes active on the next query call.
 *
 * @param timeoutInSeconds the max amount of seconds the query can take to execute.
 */
@Fluent
@Deprecated
default SQLConnection setQueryTimeout(int timeoutInSeconds) {
 setOptions(new SQLOptions().setQueryTimeout(timeoutInSeconds));
 return this;
}

代码示例来源:origin: io.vertx/vertx-lang-groovy

public static io.vertx.ext.sql.SQLConnection setOptions(io.vertx.ext.sql.SQLConnection j_receiver, java.util.Map<String, Object> options) {
 io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.setOptions(options != null ? new io.vertx.ext.sql.SQLOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null));
 return j_receiver;
}
public static io.vertx.ext.sql.SQLConnection query(io.vertx.ext.sql.SQLConnection j_receiver, java.lang.String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {

代码示例来源:origin: io.vertx/vertx-jdbc-client

@Test
public void testInsertWithParameters() {
 final TimeZone tz = TimeZone.getDefault();
 TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
 SQLConnection conn = connection();
 String sql = "INSERT INTO insert_table VALUES (?, ?, ?, ?);";
 JsonArray params = new JsonArray().addNull().add("doe").add("jane").add("2002-02-02");
 conn
  .setOptions(new SQLOptions().setAutoGeneratedKeys(true))
  .updateWithParams(sql, params, onSuccess(result -> {
   assertUpdate(result, 1);
   int id = result.getKeys().getInteger(0);
   conn.queryWithParams("SElECT DOB FROM insert_table WHERE id=?;", new JsonArray().add(id), onSuccess(resultSet -> {
    assertNotNull(resultSet);
    assertEquals(1, resultSet.getResults().size());
    assertEquals("2002-02-02", resultSet.getResults().get(0).getString(0));
    TimeZone.setDefault(tz);
    testComplete();
   }));
  }));
 await();
}

代码示例来源:origin: io.vertx/vertx-jdbc-client

@Test
public void testInsertWithNullParameters() {
 SQLConnection conn = connection();
 String sql = "INSERT INTO insert_table (lname, fname, dob) VALUES (?, ?, ?)";
 JsonArray params = new JsonArray().addNull().addNull().add("2002-02-02");
 conn
  .setOptions(new SQLOptions().setAutoGeneratedKeys(true))
  .updateWithParams(sql, params, onSuccess(result -> {
   assertUpdate(result, 1);
   int id = result.getKeys().getInteger(0);
   conn.queryWithParams("SElECT DOB FROM insert_table WHERE id=?", new JsonArray().add(id), onSuccess(resultSet -> {
    assertNotNull(resultSet);
    assertEquals(1, resultSet.getResults().size());
    System.out.println(resultSet.getResults().get(0).getValue(0));
    testComplete();
   }));
  }));
 await();
}

代码示例来源:origin: io.vertx/vertx-jdbc-client

.setOptions(new SQLOptions().setAutoGeneratedKeys(true))
.updateWithParams(sql, params, onSuccess((UpdateResult result) -> {
 assertUpdate(result, 1);

代码示例来源:origin: io.vertx/vertx-jdbc-client

@Test
public void testSelectTx() {
 String sql = "INSERT INTO insert_table VALUES (?, ?, ?, ?);";
 JsonArray params = new JsonArray().addNull().add("smith").add("john").add("2003-03-03");
 client.getConnection(onSuccess(conn -> {
  assertNotNull(conn);
  conn.setAutoCommit(false, onSuccess(v -> {
   conn
    .setOptions(new SQLOptions().setAutoGeneratedKeys(true))
    .updateWithParams(sql, params, onSuccess((UpdateResult updateResult) -> {
     assertUpdate(updateResult, 1);
     int id = updateResult.getKeys().getInteger(0);
     // Explicit typing of resultset is not really necessary but without it IntelliJ reports
     // syntax error :(
     conn.queryWithParams("SELECT LNAME FROM insert_table WHERE id = ?", new JsonArray().add(id), onSuccess((ResultSet resultSet) -> {
      assertFalse(resultSet.getResults().isEmpty());
      assertEquals("smith", resultSet.getResults().get(0).getString(0));
      testComplete();
     }));
    }));
  }));
 }));
 await();
}

相关文章