0
![我輸入圖片描述] [1]我正在嘗試更新MySQL數據庫表中的數據。 我無法做到,因爲我是初學者,所以我不知道該怎麼做,請好好指導我。 我將感謝您..............杜鬆的用JDBC更新查詢mysql
部分產生異常:
java.sql.PreparedStatement statement = conection.prepareStatement("UPDATE patient_details set `Reg_Date`='?', `Name`='?', `Father_Husband_Name`='?', `Address`='?', `City`='?', `Cell_No`='?', `Martial_Status`='?', `Gender`='?', `Status`='?', `Age`='?' where 'Reg_No'='temp'");
statement.setInt(1, temp);
statement.setString(2,textField_3.getText());
statement.setString(3,textField_1.getText());
statement.setString(4,textField_2.getText());
statement.setString(5,textArea.getText());
statement.setString(6,textField_4.getText());
statement.setString(7,textField_5.getText());
statement.setString(8,(String) comboBox.getSelectedItem());
statement.setString(9,(String) comboBox_1.getSelectedItem());
statement.setString(10,(String) comboBox_2.getSelectedItem());
statement.setInt(11,temp1);
statement.executeUpdate();
例外是: 參數超出範圍(1>參數數量爲0)
http://docs.oracle.com/javase/tutorial/jdbc/basics/prepared.html這將幫助你 – DRastislav
它會幫助,如果你能提供整個例外堆棧跟蹤 – crownjewel82
好吧,看看等待請... –