【发布时间】:2015-08-07 04:38:15
【问题描述】:
// 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);
}
怎么了?如果我添加列这显示问题
参数索引超出范围(1>参数个数,即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();
}
【问题讨论】:
-
update table_name set col1='val1', col2='val2',... where col1='something' -
无法判断这里出了什么问题,因为我们不知道您的表中有什么或您调用
getText()的所有这些类。请澄清你的问题。您的查询中还有五个绑定参数?,但只有四个参数加上您正在调用的DbConnection方法的查询字符串。 -
如果我使用'参数值问题:S
-
你觉得这段代码怎么样? DBConnection 这里