最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

老師桑,請(qǐng)教問(wèn)題

String sql="select * from items where id=?;";
stmt=conn.prepareStatement(sql);
stmt.setInt(1,id);

沒(méi)看懂為什么這么做

正在回答

3 回答


?void?setInt(int?parameterIndex,?int?x)?throws?SQLException;

????/**
?????*?Sets?the?designated?parameter?to?the?given?Java?<code>long</code>?value.
?????*?The?driver?converts?this
?????*?to?an?SQL?<code>BIGINT</code>?value?when?it?sends?it?to?the?database.
?????*
?????*?@param?parameterIndex?the?first?parameter?is?1,?the?second?is?2,?...
?????*?@param?x?the?parameter?value
?????*?@exception?SQLException?if?parameterIndex?does?not?correspond?to?a?parameter
?????*?marker?in?the?SQL?statement;?if?a?database?access?error?occurs?or
?????*?this?method?is?called?on?a?closed?<code>PreparedStatement</code>
?????*/

api源代碼。jdbc不太懂的換可以先學(xué)學(xué)jdbc篇。

setInt(int parameterIndex, int x):方法

給指定的參數(shù)賦指定的值;

參數(shù)int parameterIndex是jdbc傳入sql語(yǔ)句中的每個(gè)問(wèn)號(hào)?的index;第一個(gè)問(wèn)號(hào)是1,第二個(gè)問(wèn)號(hào)是2…;

參數(shù)?int x是你設(shè)定的值,在這里傳的是變量id;

2 回復(fù) 有任何疑惑可以回復(fù)我~

你好,String sql="select * from items where id=?;";這個(gè)是寫(xiě)了個(gè)sql語(yǔ)句,sql應(yīng)該懂吧,這里就是查items這個(gè)表里某個(gè)id的數(shù)據(jù);stmt=conn.prepareStatement(sql);這句是調(diào)方法執(zhí)行這個(gè)sql語(yǔ)句,返回你要的數(shù)據(jù),你就可以處理了。

望樓主采納!

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

激流勇進(jìn)__

stmt.setInt(1,id);這句是神么意思??
2016-02-09 回復(fù) 有任何疑惑可以回復(fù)我~
#2

愛(ài)你無(wú)痕_ 回復(fù) 激流勇進(jìn)__

看一樓的解釋,很清楚的
2018-02-06 回復(fù) 有任何疑惑可以回復(fù)我~

執(zhí)行sql語(yǔ)句的基本步驟,暫時(shí)看不懂沒(méi)關(guān)系,依葫蘆畫(huà)瓢就好

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

老師桑,請(qǐng)教問(wèn)題

我要回答 關(guān)注問(wèn)題
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

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