Berker
Berker

Reputation: 15

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

this is my button

 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);
        }
    }

and this is my connection and i think problems THERE but i dont find

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();

}

}

Upvotes: 1

Views: 63

Answers (1)

Eran
Eran

Reputation: 394146

You should unquote all the place holders (?) and add conditions to your WHERE clause :

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

Upvotes: 1

Related Questions