您好,我可以正确连接到MySQL数据库,我可以显示所有数据,但是不能使用我的班级插入任何值:
public void addBook(Book theBook) throws Exception {
Connection myConn = null;
PreparedStatement myStmt = null;
try {
myConn = dataSource.getConnection();
String sqlInsert = "INSERT INTO `rezerwacje_miejsc` "
+ "(`NR_MIEJSCA`, `START`, `KONIEC`, `IMIE_NAZWISKO`, `TELEFON`) "
+ "VALUES (?, ?, ?, ?, ?)";
myStmt = myConn.prepareStatement(sqlInsert);
myStmt.setInt(1, theBook.getNumber());
myStmt.setDate(2, new java.sql.Date(theBook.getStart().getTime()));
myStmt.setDate(3, new java.sql.Date(theBook.getEnd().getTime()));
myStmt.setString(4, theBook.getUserName());
myStmt.setInt(5, theBook.getPhone());
myStmt.execute();
} finally {
close(myConn, myStmt, null);
}
}
我没有错误,只是在数据库上没有插入(也已在phpMyAdmin上手动检查,以确保它不是.jsp显示问题,然后我试图检查我的查询,但似乎没问题。我用光了)想法