1

データベース内で更新ステートメントを実行する次のメソッドを作成しました。

 public boolean updateEmployee(int id){
    try {
        String update="UPDATE employee set name='updatedName' and address='updatedaddress' where id=(?)";
        pst=connection.prepareStatement(update);
        pst.setInt(1, id);
        pst.executeUpdate();

    } catch (SQLException ex) {
        Logger.getLogger(DAO.class.getName()).log(Level.SEVERE, null, ex);
        return false;
    }
    return true;
 }

ただし、次の例外が発生します。

java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

そして、この例外もスローされます:

com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'UpdatedName'

ここで何が問題なのですか?さらに、更新ステートメントの結果を返すにはどうすればよいですか ( executeQueryDML ステートメントでは機能しないため)。

4

2 に答える 2

5

クローズされていない見積もりの​​問題のように見えますか?

name='updatedname and address
于 2013-02-01T17:46:32.263 に答える