File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes inserting date into ms access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "inserting date into ms access" Watch "inserting date into ms access" New topic
Author

inserting date into ms access

damien farry
Greenhorn

Joined: Mar 22, 2001
Posts: 6
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

Joined: May 05, 2000
Posts: 13974
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


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inserting date into ms access
 
Similar Threads
convert a String into Date with SimpleDateFormat
Java date to MySQL date conversion
preparedStatement.setDate and java.util.Date
Converting From String to java.sql.Date
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Opti onal fature not implem