Hi, I'm trying to use PreparedStatement.setTimestamp() on a column which is in DATETIME format and I think there is a bug in SQLiteJDBC:
The argument is supposed to be milliseconds since 1970, but SQLiteJDBC treats this value as seconds. Consider the following example, which should insert the current time into a table: Class.forName("org.sqlite.JDBC"); Connection conn = DriverManager.getConnection("jdbc:sqlite:"); Statement stat = conn.createStatement(); stat.executeUpdate("CREATE TABLE tickets(requestTimeStamp DATETIME)"); PreparedStatement prep = conn.prepareStatement( "INSERT INTO tickets VALUES(datetime(?, 'unixepoch', 'localtime'))"); java.util.Date date = new java.util.Date(); prep.setTimestamp(1, new Timestamp(date.getTime())); prep.executeUpdate(); ResultSet rs = stat.executeQuery("SELECT * FROM tickets"); while (rs.next()) { System.out.println(rs.getString(1)); } rs.close(); conn.close(); This will insert a nonsense timestamp, but prep.setTimestamp(1, new Timestamp(date.getTime()/1000)); will do the right thing. --~--~---------~--~----~------------~-------~--~----~ Mailing List: http://groups.google.com/group/sqlitejdbc?hl=en To unsubscribe, send email to [EMAIL PROTECTED] -~----------~----~----~----~------~----~------~--~---