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


Java CallableStatement.getUpdateCount方法代碼示例

本文整理匯總了Java中java.sql.CallableStatement.getUpdateCount方法的典型用法代碼示例。如果您正苦於以下問題:Java CallableStatement.getUpdateCount方法的具體用法?Java CallableStatement.getUpdateCount怎麽用?Java CallableStatement.getUpdateCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.sql.CallableStatement的用法示例。


在下文中一共展示了CallableStatement.getUpdateCount方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例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,代碼來源:DB2Dialect.java

示例5: 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

示例6: 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


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