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


Java Statement.getMoreResults方法代碼示例

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

示例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();
		}
	}
}
 
開發者ID:kineticadb,項目名稱:kinetica-client-jdbc,代碼行數:47,代碼來源:JDBCSample.java


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