Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Formating Date objects

 
Dave Kinkead
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to time stamp an object when sending it to a MS Access database but am struggling to format the date object correctly. When the date component of my statement is removed, the excecuteStatement() method works just fine so Im sure it is the date format.
How do I format it correctly to MS Access format so I don't get anymore 30 line SQLExceptions!?!
Thanks in advance
Dave
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could probably work it out with a SimpleDateFormat and knowing what format Access likes. However, I suggest using a PreparedStatement, and then using the setDate() method. That way the driver would just figure it out for you.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
Does this help you? It inserts a row into a database table (named "Table1") that has two columns:
  • name with datatype Text
  • updated with datatype Date/Time

  • The below code was tested on Windows XP with Micro$oft Access and J2SE SDK 1.4.1_02

    Of-course, if the above is totally useless to you then
  • Please excuse me.
  • Provide some more details so I can (hopefully) give you something useful instead

  • Good Luck,
    Avi.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic