本文整理汇总了Java中java.sql.CallableStatement.setFetchSize方法的典型用法代码示例。如果您正苦于以下问题:Java CallableStatement.setFetchSize方法的具体用法?Java CallableStatement.setFetchSize怎么用?Java CallableStatement.setFetchSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.CallableStatement
的用法示例。
在下文中一共展示了CallableStatement.setFetchSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import java.sql.CallableStatement; //导入方法依赖的package包/类
public CallableStatement apply(Connection input, Object... args) {
try {
CallableStatement call;
if (!skip) {
log.debug("applying {} on input Connection", this);
if (holdability == ResultSetHoldability.DEFAULT) {
call = input.prepareCall((String) args[0], type.getValue(), concurrency.getValue());
} else {
call = input.prepareCall((String) args[0], type.getValue(), concurrency.getValue(), holdability.getValue());
}
call.setFetchDirection(fetchDirection.getValue());
call.setFetchSize(fetchSize);
call.setMaxFieldSize(maxFieldSize);
call.setMaxRows(maxRows);
} else {
call = input.prepareCall((String) args[0]);
}
return call;
} catch (SQLException e) {
throw new CallException(e);
}
}
示例2: testBug33678
import java.sql.CallableStatement; //导入方法依赖的package包/类
/**
* Tests fix for Bug#33678 - Multiple result sets not supported in
* "streaming" mode. This fix covers both normal statements, and stored
* procedures, with the exception of stored procedures with registered
* OUTPUT parameters, which can't be used at all with "streaming" result
* sets.
*
* @throws Exception
*/
public void testBug33678() throws Exception {
if (!versionMeetsMinimum(4, 1)) {
return;
}
createTable("testBug33678", "(field1 INT)");
Connection multiConn = getConnectionWithProps("allowMultiQueries=true");
Statement multiStmt = multiConn.createStatement();
try {
multiStmt.setFetchSize(Integer.MIN_VALUE);
multiStmt.execute("SELECT 1 UNION SELECT 2; INSERT INTO testBug33678 VALUES (1); UPDATE testBug33678 set field1=2; "
+ "INSERT INTO testBug33678 VALUES(3); UPDATE testBug33678 set field1=2 WHERE field1=3; UPDATE testBug33678 set field1=2; SELECT 1");
this.rs = multiStmt.getResultSet();
this.rs.next();
assertEquals("1", this.rs.getString(1));
assertFalse(multiStmt.getMoreResults());
assertEquals(1, multiStmt.getUpdateCount());
assertFalse(multiStmt.getMoreResults());
assertEquals(1, multiStmt.getUpdateCount());
assertFalse(multiStmt.getMoreResults());
assertEquals(1, multiStmt.getUpdateCount());
assertFalse(multiStmt.getMoreResults());
assertEquals(1, multiStmt.getUpdateCount());
assertFalse(multiStmt.getMoreResults());
assertEquals(2, multiStmt.getUpdateCount());
assertTrue(multiStmt.getMoreResults());
this.rs = multiStmt.getResultSet();
this.rs.next();
assertEquals("1", this.rs.getString(1));
this.rs.close();
multiStmt.execute("INSERT INTO testBug33678 VALUES (1); INSERT INTO testBug33678 VALUES (1), (2); INSERT INTO testBug33678 VALUES (1), (2), (3)");
assertEquals(1, multiStmt.getUpdateCount());
assertFalse(multiStmt.getMoreResults());
assertEquals(2, multiStmt.getUpdateCount());
assertFalse(multiStmt.getMoreResults());
assertEquals(3, multiStmt.getUpdateCount());
assertFalse(multiStmt.getMoreResults() && multiStmt.getUpdateCount() == -1);
this.rs.close();
if (versionMeetsMinimum(5, 0)) {
createProcedure("spBug33678", "() BEGIN SELECT 1; SELECT 2; SELECT 3; END");
CallableStatement cStmt = multiConn.prepareCall("{CALL spBug33678()}");
cStmt.setFetchSize(Integer.MIN_VALUE);
cStmt.execute();
for (int i = 0; i < 2; i++) {
if (i != 0) {
assertTrue(cStmt.getMoreResults());
}
this.rs = cStmt.getResultSet();
assertTrue(this.rs.next());
assertEquals(i + 1, this.rs.getInt(1));
}
}
} finally {
multiStmt.close();
multiConn.close();
}
}