本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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;
}