本文整理汇总了Java中java.sql.Statement.executeLargeUpdate方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.executeLargeUpdate方法的具体用法?Java Statement.executeLargeUpdate怎么用?Java Statement.executeLargeUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.Statement
的用法示例。
在下文中一共展示了Statement.executeLargeUpdate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeLargeUpdate
import java.sql.Statement; //导入方法依赖的package包/类
public final long executeLargeUpdate(String sql, Object... args) {
if (!isConnected()) {
return -1;
}
String temp = null;
try {
temp = (args != null && args.length != 0) ? String.format(sql, args) : sql;
if (DEBUG_SQL) {
System.out.println(temp);
}
final Statement statement = createStatement();
final long result = statement.executeLargeUpdate(temp);
statement.close();
return result;
} catch (Exception ex) {
System.err.println("Database: Executing large update error");
if (DEBUG) {
System.err.println("SQL: " + temp);
}
ex.printStackTrace();
return -1;
}
}
示例2: shouldMeasureStatement
import java.sql.Statement; //导入方法依赖的package包/类
/**
* Should measure statement.
*
* @throws SQLException
* the SQL exception
*/
@Test
public void shouldMeasureStatement() throws SQLException {
Statement statements[] = { dataSource.getConnection().createStatement(),
dataSource.getConnection().createStatement(1, 1), dataSource.getConnection().createStatement(1, 1, 1) };
for (Statement statement : statements) {
statement.execute("select");
statement.execute("select", 1);
statement.execute("select", new int[] {});
statement.execute("select", new String[] {});
statement.executeQuery("select");
statement.executeUpdate("select");
statement.executeUpdate("select", 1);
statement.executeUpdate("select", new int[] {});
statement.executeUpdate("select", new String[] {});
statement.executeLargeUpdate("select");
statement.executeLargeUpdate("select", 1);
statement.executeLargeUpdate("select", new int[] {});
statement.executeLargeUpdate("select", new String[] {});
statement.addBatch("select");
statement.executeBatch();
statement.executeLargeBatch();
}
assertThat(registry.get("jdbc.Statement.Invocations", "select")).isEqualTo(1L * 15 * statements.length);
assertThat(registry.get("jdbc.Statement.Durations", "select")).isEqualTo(123456789L * 15 * statements.length);
}
示例3: executeExecuteLargeUpdateSamples
import java.sql.Statement; //导入方法依赖的package包/类
public void executeExecuteLargeUpdateSamples(String sql) throws SQLException {
Statement stmt = con.createStatement();
stmt.executeLargeUpdate(sql);
stmt.executeLargeUpdate(sql, Statement.RETURN_GENERATED_KEYS);
stmt.executeLargeUpdate(sql, new int[]{1, 2, 3});
stmt.executeLargeUpdate(sql, new String[]{"firstname", "middlename", "lastname"});
}