我有这个在我的try子句…如果我去掉pst.setString(5, value5)
,它工作得很好,它也可以工作,如果我删除所有的整数值,但我不能得到它的工作,如果所有的整数和value5被添加…
try {
Class.forName("org.postgresql.Driver");
connection = DriverManager.getConnection(connectionURL, "username", "password");
String sql ="UPDATE table1 SET value1 = ?, value2 = ?, value3 = ?, value4 = ? value5 = ? WHERE value6 = ? ";
PreparedStatement pst = connection.prepareStatement(sql);
Integer value1A = Integer.parseInt(value1),
value2A = Integer.parseInt(value2),
value2A = Integer.parseInt(value3),
value2A = Integer.parseInt(value4);
pst.setInt(1, value1A);
pst.setInt(2, value2A);
pst.setInt(3, value3A);
pst.setInt(4, value4A);
pst.setString(5, value5);
pst.setString(6, value6);
int numRowsChanged = pst.executeUpdate();
pst.close();
}
您的SQL
中缺少一个逗号:
String sql ="UPDATE table1 SET value1 = ?, value2 = ?, value3 = ?, value4 = ?, value5 = ? WHERE value6 = ? ";
^
似乎你缺少一个逗号?