当前位置: 首页>>代码示例>>Java>>正文


Java CallableStatement.getMoreResults方法代码示例

本文整理汇总了Java中java.sql.CallableStatement.getMoreResults方法的典型用法代码示例。如果您正苦于以下问题:Java CallableStatement.getMoreResults方法的具体用法?Java CallableStatement.getMoreResults怎么用?Java CallableStatement.getMoreResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.CallableStatement的用法示例。


在下文中一共展示了CallableStatement.getMoreResults方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testThree

import java.sql.CallableStatement; //导入方法依赖的package包/类
public void testThree() throws SQLException {

        Connection conn = newConnection();
        Statement  st   = conn.createStatement();

        st.execute("declare varone int default 0;");
        st.execute(
            "create procedure proc_inout_result (inout intp int) "
            + " language java reads sql data external name 'CLASSPATH:org.hsqldb.test.TestStoredProcedure.procWithResultOne'");

        CallableStatement cs =
            conn.prepareCall("call proc_inout_result(varone)");
        boolean isResult = cs.execute();

        assertFalse(isResult);
        cs.getMoreResults();

        ResultSet rs = cs.getResultSet();

        rs.next();
        assertEquals(rs.getString(1), "SYSTEM_LOBS");
        assertEquals(rs.getString(2), "LOB_IDS");
        rs.close();
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:25,代码来源:TestStoredProcedure.java

示例2: testFour

import java.sql.CallableStatement; //导入方法依赖的package包/类
public void testFour() throws SQLException {

        Connection conn = newConnection();
        Statement  st   = conn.createStatement();

        st.execute("declare varone int default 0;");
        st.execute(
            "create procedure proc_inout_result_two (inout intp int) "
            + " language java reads sql data dynamic result sets 2 external name 'CLASSPATH:org.hsqldb.test.TestStoredProcedure.procWithResultTwo'");

        CallableStatement cs =
            conn.prepareCall("call proc_inout_result_two(varone)");
        boolean isResult = cs.execute();

        assertFalse(isResult);
        cs.getMoreResults();

        ResultSet rs = cs.getResultSet();

        rs.next();
        assertEquals(rs.getString(1), "SYSTEM_LOBS");
        assertEquals(rs.getString(2), "LOB_IDS");
        rs.close();

        if (cs.getMoreResults()) {
            rs = cs.getResultSet();

            rs.next();
            assertEquals(rs.getString(1), "SYSTEM_LOBS");
            assertEquals(rs.getString(2), "LOBS");
            rs.close();
        }
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:34,代码来源:TestStoredProcedure.java

示例3: getResultSet

import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public ResultSet getResultSet(CallableStatement ps) throws SQLException {
	boolean isResultSet = ps.execute();
	while ( !isResultSet && ps.getUpdateCount() != -1 ) {
		isResultSet = ps.getMoreResults();
	}
	return ps.getResultSet();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:MySQLDialect.java

示例4: getResultSet

import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public ResultSet getResultSet(CallableStatement ps) throws SQLException {
	boolean isResultSet = ps.execute();
	// This assumes you will want to ignore any update counts
	while (!isResultSet && ps.getUpdateCount() != -1) { 
		isResultSet = ps.getMoreResults();
	}

	return ps.getResultSet();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:DataDirectOracle9Dialect.java

示例5: getResultSet

import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public ResultSet getResultSet(CallableStatement ps) throws SQLException {
	boolean isResultSet = ps.execute();
	// This assumes you will want to ignore any update counts
	while ( !isResultSet && ps.getUpdateCount() != -1 ) {
		isResultSet = ps.getMoreResults();
	}

	// You may still have other ResultSets or update counts left to process here
	// but you can't do it now or the ResultSet you just got will be closed
	return ps.getResultSet();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:AbstractTransactSQLDialect.java

示例6: getResultSet

import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public ResultSet getResultSet(CallableStatement ps) throws SQLException {
	boolean isResultSet = ps.execute();
	// This assumes you will want to ignore any update counts 
	while ( !isResultSet && ps.getUpdateCount() != -1 ) {
		isResultSet = ps.getMoreResults();
	}

	return ps.getResultSet();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:DB2Dialect.java

示例7: testFourParams

import java.sql.CallableStatement; //导入方法依赖的package包/类
public void testFourParams() throws SQLException {

        Connection conn = newConnection();
        Statement  st   = conn.createStatement();

        st.execute(
            "create procedure proc_inout_result_two_params (inout intp int) "
            + " language java reads sql data dynamic result sets 2 external name 'CLASSPATH:org.hsqldb.test.TestStoredProcedure.procWithResultTwo'");

        CallableStatement cs =
            conn.prepareCall("{call proc_inout_result_two_params(?)}");

        cs.setInt(1, 0);

        boolean isResult = cs.execute();

        assertFalse(isResult);
        cs.getMoreResults();

        ResultSet rs = cs.getResultSet();

        rs.next();
        assertEquals(rs.getString(1), "SYSTEM_LOBS");
        assertEquals(rs.getString(2), "LOB_IDS");
        rs.close();

        if (cs.getMoreResults()) {
            rs = cs.getResultSet();

            rs.next();
            assertEquals(rs.getString(1), "SYSTEM_LOBS");
            assertEquals(rs.getString(2), "LOBS");
            rs.close();
        }

        rs = cs.executeQuery();

        rs.next();
        assertEquals(rs.getString(1), "SYSTEM_LOBS");
        assertEquals(rs.getString(2), "LOB_IDS");
        rs.close();
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:43,代码来源:TestStoredProcedure.java

示例8: testB

import java.sql.CallableStatement; //导入方法依赖的package包/类
public void testB() throws SQLException, ClassNotFoundException {

        Statement statement = con.createStatement();

        statement.execute(
            "CREATE TABLE IF NOT EXISTS users (id INTEGER, name VARCHAR(25), PRIMARY KEY(id))");
        statement.executeUpdate("INSERT INTO users VALUES(1, 'Ramiro')");
        statement.executeUpdate("INSERT INTO users VALUES(2, 'Chanukya')");

        String storedProcedure1 =
            "CREATE PROCEDURE sp_say_hi(IN greeting_p VARCHAR(10)) "
            + "READS SQL DATA DYNAMIC RESULT SETS 2 " + "BEGIN ATOMIC "
            + "DECLARE result CURSOR WITH RETURN FOR SELECT COALESCE(greeting_p, 'Hi')+' '+name as greeting FROM users FOR READ ONLY; "
            + "DECLARE result1 CURSOR WITH RETURN FOR SELECT * FROM users FOR READ ONLY; "
            + "OPEN result; " + "OPEN result1; " + "END";

        statement.execute(storedProcedure1);

        String            sqlCall           = "CALL sp_say_hi(?)";
        CallableStatement callableStatement = con.prepareCall(sqlCall);

        callableStatement.setObject("GREETING_P", "Hola");

        boolean result = callableStatement.execute();

        if (!result) {
            int value = callableStatement.getUpdateCount();

            assertTrue(value == 0);
            result = callableStatement.getMoreResults();
            assertTrue(result);
            ResultSet result1 = callableStatement.getResultSet();
            result = callableStatement.getMoreResults();
            assertTrue(result);
            ResultSet result2 = callableStatement.getResultSet();
            result = callableStatement.getMoreResults();
            assertFalse(result);
            value = callableStatement.getUpdateCount();
            assertTrue(value == -1);

        }
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:43,代码来源:TestPreparedStatements.java

示例9: extractReturnedResults

import java.sql.CallableStatement; //导入方法依赖的package包/类
/**
 * Extract returned ResultSets from the completed stored procedure.
 * @param cs JDBC wrapper for the stored procedure
 * @param updateCountParameters Parameter list of declared update count parameters for the stored procedure
 * @param resultSetParameters Parameter list of declared resultSet parameters for the stored procedure
 * @return Map that contains returned results
 */
protected Map<String, Object> extractReturnedResults(CallableStatement cs,
		List<SqlParameter> updateCountParameters, List<SqlParameter> resultSetParameters, int updateCount)
		throws SQLException {

	Map<String, Object> returnedResults = new HashMap<String, Object>();
	int rsIndex = 0;
	int updateIndex = 0;
	boolean moreResults;
	if (!this.skipResultsProcessing) {
		do {
			if (updateCount == -1) {
				if (resultSetParameters != null && resultSetParameters.size() > rsIndex) {
					SqlReturnResultSet declaredRsParam = (SqlReturnResultSet) resultSetParameters.get(rsIndex);
					returnedResults.putAll(processResultSet(cs.getResultSet(), declaredRsParam));
					rsIndex++;
				}
				else {
					if (!this.skipUndeclaredResults) {
						String rsName = RETURN_RESULT_SET_PREFIX + (rsIndex + 1);
						SqlReturnResultSet undeclaredRsParam = new SqlReturnResultSet(rsName, new ColumnMapRowMapper());
						if (logger.isDebugEnabled()) {
							logger.debug("Added default SqlReturnResultSet parameter named '" + rsName + "'");
						}
						returnedResults.putAll(processResultSet(cs.getResultSet(), undeclaredRsParam));
						rsIndex++;
					}
				}
			}
			else {
				if (updateCountParameters != null && updateCountParameters.size() > updateIndex) {
					SqlReturnUpdateCount ucParam = (SqlReturnUpdateCount) updateCountParameters.get(updateIndex);
					String declaredUcName = ucParam.getName();
					returnedResults.put(declaredUcName, updateCount);
					updateIndex++;
				}
				else {
					if (!this.skipUndeclaredResults) {
						String undeclaredName = RETURN_UPDATE_COUNT_PREFIX + (updateIndex + 1);
						if (logger.isDebugEnabled()) {
							logger.debug("Added default SqlReturnUpdateCount parameter named '" + undeclaredName + "'");
						}
						returnedResults.put(undeclaredName, updateCount);
						updateIndex++;
					}
				}
			}
			moreResults = cs.getMoreResults();
			updateCount = cs.getUpdateCount();
			if (logger.isDebugEnabled()) {
				logger.debug("CallableStatement.getUpdateCount() returned " + updateCount);
			}
		}
		while (moreResults || updateCount != -1);
	}
	return returnedResults;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:64,代码来源:JdbcTemplate.java

示例10: newInstance

import java.sql.CallableStatement; //导入方法依赖的package包/类
/**
 * Populates instance of SqlResults using rows from ResultSet.
 *
 * @param cstmt
 *            Statement whose rows are to be read.
 */
public static StoreResults newInstance(CallableStatement cstmt) {
    StoreResults storeResults = new StoreResults();
    try {
        do {
            ResultSet rs = cstmt.getResultSet();
            if (rs == null) {
                return storeResults;
            }
            if (!rs.next()) { // move to first row.
                continue;
            }
            SqlResultType resultType = resultFromColumnName.get(rs.getMetaData().getColumnLabel(2));
            switch (resultType) {
                case ShardMap:
                    do {
                        storeResults.getStoreShardMaps().add(readShardMap(rs, 2));
                    }
                    while (rs.next());
                    break;
                case Shard:
                    do {
                        storeResults.getStoreShards().add(readShard(rs, 2));
                    }
                    while (rs.next());
                    break;
                case ShardMapping:
                    do {
                        storeResults.getStoreMappings().add(readMapping(rs, 2));
                    }
                    while (rs.next());
                    break;
                case ShardLocation:
                    do {
                        storeResults.getStoreLocations().add(readLocation(rs, 2));
                    }
                    while (rs.next());
                    break;
                case SchemaInfo:
                    do {
                        storeResults.getStoreSchemaInfoCollection().add(readSchemaInfo(rs, 2));
                    }
                    while (rs.next());
                    break;
                case StoreVersion:
                    do {
                        storeResults.setStoreVersion(readVersion(rs, 2));
                    }
                    while (rs.next());
                    break;
                case Operation:
                    do {
                        storeResults.getLogEntries().add(readLogEntry(rs, 2));
                    }
                    while (rs.next());
                    break;
                default:
                    break;
            }
        }
        while (cstmt.getMoreResults());

    }
    catch (SQLException e) {
        e.printStackTrace();
    }
    return storeResults;
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:74,代码来源:SqlResults.java

示例11: executeCall

import java.sql.CallableStatement; //导入方法依赖的package包/类
@Override
public boolean executeCall(CallableStatement call) throws SQLException {
    super.executeCall(call);
    return call.getMoreResults();
}
 
开发者ID:mhewedy,项目名称:spwrap,代码行数:6,代码来源:HSQL.java


注:本文中的java.sql.CallableStatement.getMoreResults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。