當前位置: 首頁>>代碼示例>>Java>>正文


Java CallableStatement.setFetchSize方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:mhewedy,項目名稱:spwrap,代碼行數:26,代碼來源:ResultSetProps.java

示例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();
    }
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:79,代碼來源:ResultSetRegressionTest.java


注:本文中的java.sql.CallableStatement.setFetchSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。