File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inserting date into ms access

 
damien farry
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, looked at previous posts and tried this code to add to my access database:
--------------------------------------------------
java.util.Date d = new java.util.Date();
java.sql.Date date = new java.sql.Date(d.getDate());

PreparedStatement ps;
ps = myConn.prepareStatement("INSERT INTO TestTable"+"(Eventdate)"+ "values (?)");
ps.setDate(1,date);
ps.execute();
------------------------------------------------
I tried this and got an java.sql.SQLException: General error
Having serious problems with this i am trying to create a calendar system in JSP so the date is key to my code

 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting spaces between the pieces:


ps = myConn.prepareStatement("INSERT INTO TestTable "+"(Eventdate)"+ " values (?)");
Right now your statement would look like:
INSERT INTO TestTable(Eventdate)values (?)

------------------
Moderator of the JDBC Forum
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic