// my button
public void actionPerformed(ActionEvent arg0) {
String sorgu="UPDATE calisan SET CalisanAdi=? AND CalisanSoyadi=? AND kul_adi=? AND sifre=? WHERE idcalisan=? ";
DBConnection.KullaniciGuncelle(calisan_ad.getText(), calisan_soyad.getText(),calisan_kul_adi.getText(), calisan_sifre.getText(), sorgu);
}
What's wrong? If I add column this show problems
parameter index out of range (1 > number of parameters, which is 0)
public static void KullaniciGuncelle(String ad, String soyad, String kadi, String sifre,String sorgu){
connection();
try
{
Connection connect = DriverManager.getConnection(host, username , pass);
PreparedStatement statement = (PreparedStatement) connect.prepareStatement(sorgu);
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();
}
You're only binding four parameters in your update method. But your query string contains five. Also, you're misusing AND
in your query.
The query should be this, removing the extra AND
items.
UPDATE calisan
SET CalisanAdi=?, CalisanSoyadi=?,
kul_adi=?, sifre=?
WHERE idcalisan=? ";
Your update method needs an extra parameter bind for the fifth ?
. I guess idcalisan
is an ID (even though I'm ignorant of Turkish, sorry) so I've suggested setInt()
.
statement.setString(1, ad);
statement.setString(2, soyad);
statement.setString(3, kadi);
statement.setString(4, sifre);
statement.setInt (5, idcalisan)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.