Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot Insert Date and Time into MS Access database

843859Aug 8 2007 — edited Aug 9 2007
I'm trying to insert the current date and time into my MS Access Database. I get no compile or run time errors and a record (row) gets created when the code is excecuted and all info is inserted correcly except the date & time. The last column (data and time) is left empty.

PreparedStatement pstmt = con.prepareStatement("INSERT INTO MyTable (a, b, c, Date)" + "VALUES(?,?,?,?)");

pstmt.setByte(1, a);
pstmt.setByte(2, b);
pstmt.setByte(3, c);

//For the last one, I use
pstmt.setTimestamp( 4, new java.sql.Timestamp( new java.util.Date().getTime()));

//or this:
//pstmt.setDate(4, new java.sql.Date(new java.util.Date().getTime()));

but neither works.

I googled this and read many of the threads here or in other forums. I found similar questions and accoording to them, what I have should work so I don't understand why it is not.

Would you please help. Thanks a lot in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 6 2007
Added on Aug 8 2007
17 comments
442 views