java.sql.SQLException:参数索引超出范围(1>参数个数,即0)问题

时间:2015-05-25 15:07:56

标签: java mysql

这是我的按钮

 btnSil.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {

            String sorgu="DELETE FROM muhasebe Where MuhasebeAdi='?', MuhasebeSoyadi='?', kul_adi='?' ,sifre='?'  ";
            DBConnection.KullaniciSil(muhasebe_ad.getText(), muhasebe_soyad.getText(), muhasebe_kul_adi.getText(), muhasebe_sifre.getText(), sorgu);
        }
    }

这是我的联系,我认为有问题,但我找不到

public static void KullaniciSil(String ad, String soyad, String kadi, String sifre,String sorgu1){

connection();

try
{
    Connection connect = DriverManager.getConnection(host, username , pass);
    PreparedStatement statement = (PreparedStatement) connect.prepareStatement(sorgu1);

    statement.setString(1, ad);
    statement.setString(2, soyad);
    statement.setString(3, kadi);
    statement.setString(4, sifre);

    statement.executeUpdate();
    statement.close();
    connect.close();


}
catch(SQLException e)
{
    e.printStackTrace();

}

}

1 个答案:

答案 0 :(得分:1)

您应该取消引用所有占位符(?)并为WHERE子句添加条件:

String sorgu="DELETE FROM muhasebe Where MuhasebeAdi=? AND MuhasebeSoyadi=? AND kul_adi=?  AND sifre=?";