【发布时间】:2018-04-23 03:10:39
【问题描述】:
我的程序应该更新 Rooms 表中的“isAvail”:
public void RemRoom() {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
try {
con = DriverManager.getConnection("jdbc:sqlite:Rooms.db");
con.setAutoCommit(false);
System.out.println("1");
pst = con.prepareStatement("UPDATE " + tp + " set isAvail = 'false' where RoomID = '" + rm + "'");
pst.execute();
pst = con.prepareStatement("Select isAvail from " + tp + " Where RoomID = '" + rm + "'");
rs = pst.executeQuery();
System.out.println(rs.toString());
System.out.println("2");
pst.close();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
它没有给我任何错误,但它没有改变那个单元格的内容。
【问题讨论】:
-
好吧对不起!你能撤消否决票吗?
-
如果您要像使用
Statement那样构建查询结构,为什么还要使用PreparedStatement?
标签: java eclipse sqlite jdbc javafx