-1

我在我的 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();
}
4

2 回答 2

5

You're missing a comma in your SQL:

String sql ="UPDATE table1 SET value1 = ?, value2 = ?, value3 = ?, value4 = ?, value5 = ? WHERE value6 = ? ";
                                                                             ^
于 2013-01-15T01:38:49.417 回答
1

it seems you are missing a comma?

于 2013-01-15T01:39:51.677 回答