當(dāng) getMoreResults 返回 false 時(shí),它表示該 SQL 語(yǔ)句返回一個(gè)更新計(jì)數(shù)或沒(méi)有其它結(jié)果 。因此需要調(diào)用方法 getUpdateCount 來(lái)檢查它是哪一種情況 。在這種情況下,當(dāng)下列條件為真時(shí)表示沒(méi)有其它結(jié)果:
((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1))
下面的代碼演示了一種方法用來(lái)確認(rèn)已訪問(wèn)調(diào)用方法 execute 所產(chǎn)生的全部結(jié)果集和更新計(jì)數(shù):
stmt.execute(queryStringWithUnknownResults);
while (true) {
int rowCount = stmt.getUpdateCount();
if (rowCount > 0) { // 它是更新計(jì)數(shù)
System.out.println(“Rows changed = ” + count);
stmt.getMoreResults();
continue;
}
if (rowCount == 0) { // DDL 命令或 0 個(gè)更新
System.out.println(” No rows changed or statement was DDL
command”);
stmt.getMoreResults();
continue;
}
// 執(zhí)行到這里,證明有一個(gè)結(jié)果集
// 或沒(méi)有其它結(jié)果
ResultSet rs = stmt.getResultSet;
if (rs != null) {
. . . // 使用元數(shù)據(jù)獲得關(guān)于結(jié)果集列的信息
while (rs.next()) {
. . . // 處理結(jié)果
stmt.getMoreResults();
continue;
}
break; // 沒(méi)有其它結(jié)果
以上關(guān)于本文的內(nèi)容,僅作參考!溫馨提示:如遇健康、疾病相關(guān)的問(wèn)題,請(qǐng)您及時(shí)就醫(yī)或請(qǐng)專業(yè)人士給予相關(guān)指導(dǎo)!
「愛(ài)刨根生活網(wǎng)」www.malaban59.cn小編還為您精選了以下內(nèi)容,希望對(duì)您有所幫助:- char在c語(yǔ)言中的用法 c語(yǔ)言中char是表示什么意思
- 講解messagebox的用法 messagebox輸出變量值
- 全球數(shù)據(jù)庫(kù)市場(chǎng)份額 全球數(shù)據(jù)庫(kù)市場(chǎng)占有
- 瑜伽伸展帶的功效及用法
- 數(shù)據(jù)庫(kù)管理系統(tǒng)的核心工作 什么是數(shù)據(jù)庫(kù)系統(tǒng)的核心
- 如何使用Oracle數(shù)據(jù)庫(kù) oracle登陸數(shù)據(jù)庫(kù)
- oracle數(shù)據(jù)庫(kù)基礎(chǔ)知識(shí) oracle數(shù)據(jù)庫(kù)類型的文件
- java filter函數(shù)的用法 object轉(zhuǎn)long問(wèn)題
- oracle數(shù)據(jù)庫(kù)菜鳥(niǎo)教程 oracle 性能優(yōu)化工具
- mysql數(shù)據(jù)庫(kù)架構(gòu)講解 mysql數(shù)據(jù)庫(kù)介紹基本情況
