本文整理匯總了Java中java.sql.Statement.getMoreResults方法的典型用法代碼示例。如果您正苦於以下問題:Java Statement.getMoreResults方法的具體用法?Java Statement.getMoreResults怎麽用?Java Statement.getMoreResults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.sql.Statement
的用法示例。
在下文中一共展示了Statement.getMoreResults方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import java.sql.Statement; //導入方法依賴的package包/類
@Override
public ResultSet execute(Statement statement, String sql) {
sqlStatementLogger.logStatement( sql );
try {
final ResultSet rs;
try {
jdbcCoordinator.getTransactionCoordinator().getTransactionContext().startStatementExecution();
if ( !statement.execute( sql ) ) {
while ( !statement.getMoreResults() && statement.getUpdateCount() != -1 ) {
// do nothing until we hit the resultset
}
}
rs = statement.getResultSet();
}
finally {
jdbcCoordinator.getTransactionCoordinator().getTransactionContext().endStatementExecution();
}
postExtract( rs, statement );
return rs;
}
catch (SQLException e) {
throw sqlExceptionHelper.convert( e, "could not execute statement" );
}
}
示例2: showQueryResult
import java.sql.Statement; //導入方法依賴的package包/類
/**
* Show the result of given query.
*
* @param conn
* The connection to use for querying the data source.
* @param sql
* The SQL query to use for querying the data source.
* @throws SQLException
* if error happens when executing the query.
*/
private static void showQueryResult(Connection conn, String sql)
throws SQLException {
System.out.println("Executing SQL query: " + sql);
Statement stmt = null;
try {
stmt = conn.createStatement();
boolean isResultSet = stmt.execute(sql);
boolean hasMoreResult = true;
while (hasMoreResult) {
if (isResultSet) {
ResultSet rs = null;
try {
rs = stmt.getResultSet();
printResultSet(rs);
} finally {
if (rs != null) {
rs.close();
}
}
} else {
int rowCount = stmt.getUpdateCount();
if (rowCount == -1) {
hasMoreResult = false;
} else {
System.out.println(String.format(
"Query OK, %d row affected.", rowCount));
}
}
isResultSet = stmt.getMoreResults();
}
} finally {
if (stmt != null) {
stmt.close();
}
}
}