-1
我有一個preparedStatement這是select = "Select * From Withdraw where CustID = ? AND AccountNo = ?;";
我如何獲得值從用戶輸入傳遞到它?如何設置PreparedStatement的值?
我有一個preparedStatement這是select = "Select * From Withdraw where CustID = ? AND AccountNo = ?;";
我如何獲得值從用戶輸入傳遞到它?如何設置PreparedStatement的值?
String query = "Select * From Withdraw where CustID = ? AND AccountNo = ?";
PreparedStatment preparedStatement = conn.prepareStatement(query);
preparedStatement.setString(1, aString);
preparedStatement.setString(2, anotherString);
rset = preparedStatement.executeQuery();
如果使用整數,有setInt(1, someInt)
的1個參數是?
。 1第一?
,2第二?
"... CustID = ? AND AccountNo = ? ..."
1 2
感謝,但什麼是數字 「1」 是指? – user3016854
重讀答案,我解釋一下。 –
這是否意味着我應該這樣寫: preparedStatement.setString(1,accNo);preparedStatement.setString(2,custID); – user3016854