我正在尝试使用sql prepared语句更新数据库,但问题是索引访问了这些参数。我正在尝试执行以下操作:
String sql =
"UPDATE table1
SET par1 = ?,
SET par2 = ?,
SET par3 = ?,
WHERE par4 =?"
但问题是我正在添加一个列并将其映射到par5。我怎样才能在这个sql语句中设置这个参数?
答案 0 :(得分:0)
String sql = "UPDATE table1 SET par1 = ?, par2 = ?, par3 = ?,WHERE par4 =?"
答案 1 :(得分:0)
PreparedStatement pstmt = null;
String sql = "UPDATE table1 SET par1 = ?, par2 = ?, par3 = ?, par5 = ? WHERE par4 =?"
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, par1);
pstmt.setString(2, par2);
pstmt.setString(3, par3);
pstmt.setString(4, par5);
pstmt.setString(5, par4);
pstmt.executeUpdate();