Store date object in sqlite database

Posted by bnabilos on Stack Overflow See other posts from Stack Overflow or by bnabilos
Published on 2010-05-29T11:20:29Z Indexed on 2010/05/29 11:22 UTC
Read the original article Hit count: 172

Filed under:
|
|

Hello,

I'm using a database in my Java project and I want to store date in it, the 5th and the 6th parameter are Date Object. I used the solution below but I have errors in these 2 lines :

        creerFilm.setDate(5, new Date (getDateDebut().getDate()));
        creerFilm.setDate(6, new Date (getDateFin().getDate()));

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());
        creerFilm.setDate(5, new Date (getDateDebut().getDate()));
        creerFilm.setDate(6, new Date (getDateFin().getDate()));
        creerFilm.executeUpdate();
        creerFilm.close();

Can you help me to fix that please ?

Thank you

© Stack Overflow or respective owner

Related posts about java

Related posts about sqlite