【发布时间】:2011-02-25 11:03:01
【问题描述】:
我在我的 Java 项目中使用了一个数据库,我想在其中存储日期,第 5 个和第 6 个参数是日期对象。我使用了下面的解决方案,但在指示的行中有错误:
PreparedStatement creerFilm = connecteur.getConnexion().prepareStatement(
"INSERT INTO FILM (ID, REF, NOM, DISTRIBUTEUR, DATEDEBUT, DATEFIN) "+
"VALUES (?, ?, ?, ?, ?, ?)");
creerFilm.setInt(1, getId());
creerFilm.setString(2, getReference());
creerFilm.setString(3, getNomFilm());
creerFilm.setString(4, getDistributeur());
// These next two lines
creerFilm.setDate(5, new Date (getDateDebut().getDate()));
creerFilm.setDate(6, new Date (getDateFin().getDate()));
// The above two lines
creerFilm.executeUpdate();
creerFilm.close();
你能帮我解决这个问题吗?
谢谢
【问题讨论】:
-
我认为 SQLite 只能存储日期和时间的 TEXT、REAL 或 INTEGER 值?