第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

“參數(shù)索引超出范圍(3 > 參數(shù)數(shù)量,即 2)。” 更新表時

“參數(shù)索引超出范圍(3 > 參數(shù)數(shù)量,即 2)。” 更新表時

冉冉說 2023-06-08 19:18:43
我正在為大學做的期末項目需要幫助,我正在做一個圖書館類系統(tǒng)。我是 mySQL 的新手。我在代碼上遇到問題,“參數(shù)索引超出范圍(3 > 參數(shù)數(shù)量,即 2)”。PreparedStatement book_edit = book_db.prepareStatement("update books set ?='?' where id=?");            book_edit.setString(1, column); //where column is to set the column of the table            book_edit.setString(2, input); //where input is what you want to change            book_edit.setInt(3, book_id); //the primary key in my database            int i = book_edit.executeUpdate();            if (i != 0) {                System.out.println("UPDATED!!");            }            else {                System.out.println("Failed to Add Data!");            }
查看完整描述

1 回答

?
瀟湘沐

TA貢獻1816條經(jīng)驗 獲得超6個贊

列名不能是 的變量PreparedStatement。它必須是 SQL 的一部分String:


PreparedStatement book_edit = book_db.prepareStatement("update books set " + column + "= ? where id = ?");


book_edit.setString(1, input); //where input is what you want to change

book_edit.setInt(2, book_id); //the primary key in my database


查看完整回答
反對 回復 2023-06-08
  • 1 回答
  • 0 關(guān)注
  • 122 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號