I have an object with a Date() member. I need to insert this in a MySql database column of type timestamp.
my code is as folllows:
String insrtSQL = "INSERT INTO run VALUES (?,?,?,?,?,NOW(),?,?)"; PreparedStatement ps = cnctn.prepareStatement(insrtSQL); ps.setString(1, this.userId); ps.setInt(2, maxRunId); ps.setTimestamp(3, new Timestamp(((Lap)this.laps.get(1)).getTs().getTime())); ps.setNull(4, Types.NULL); ps.setNull(5, Types.NULL); ps.setString(6, this.comment); ps.setNull(7, Types.NULL); ps.execute();
laps is an arraylist containing Lap objects Lap.getTs() returns a java.util.Date. As you can see, I convert java.util.Date into a java.sql.Timestamp. println shows the timestamp as populated correctly but in the database it is just zeros. Any suggestions?
ms<br />SCJP, SCJD
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads