我的try子句中有这个...如果删除pst.setString(5, value5)
,它工作正常,
如果我删除所有整数值也可以工作,但是如果添加了所有整数和值5,我就无法工作......
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();
}
答案 0 :(得分:5)
您在SQL
中错过了逗号:
String sql ="UPDATE table1 SET value1 = ?, value2 = ?, value3 = ?, value4 = ?, value5 = ? WHERE value6 = ? ";
^
答案 1 :(得分:1)