gpt4 book ai didi

java.sql.SQLException : Parameter index out of range (1 > number of parameters, 这是 0) 问题

转载 作者:行者123 更新时间:2023-11-29 12:12:13 26 4
gpt4 key购买 nike

这是我的按钮

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

}

}

最佳答案

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

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

关于java.sql.SQLException : Parameter index out of range (1 > number of parameters, 这是 0) 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30441263/

26 4 0