File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes About convert datetype 'DATETIME' From SQL (access 2000)into JAVA 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 » Java » Java in General
Bookmark "About convert datetype Watch "About convert datetype New topic
Author

About convert datetype 'DATETIME' From SQL (access 2000)into JAVA

Tracy Lee
Greenhorn

Joined: May 08, 2001
Posts: 5

when I tried to convert the data in a MS Access Database, which I create in Access 2000, all number and string worked fine. But there is a table containning a date type --- 'Date/time' with short date form e.g. today 01-05-08(yy-mm-dd). when compiling it, shows 'DATATIME' type. Java.sql.resultSet has got no method to convert it ( relevant are getDate, getTime, getTimeStamp).
Could anybody Help. I would appropriate it.
Sergei Voropay
Ranch Hand

Joined: Feb 20, 2001
Posts: 31
Just use getDate() on the ResultSet, you'll be fine.
Tracy Lee
Greenhorn

Joined: May 08, 2001
Posts: 5
I had tried before and I tried it again, Unfortunately, it doesn't work.
Thank you anyway.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Apparently, most drivers map a DATETIME to a java.sql.Timestamp, so using getTimestamp() is probably your best bet. If this doesn't work, you can probably use getString(), as that is often supported even if no other getXXX() methods are. You may be able to get a String representation of the date and time, which you can then parse with a DateFormat object to get the Date you wanted in the first place. It would be an inefficient way to go about getting a datetime, but it should work.

"I'm not back." - Bill Harding, Twister
 
Consider Paul's rocket mass heater.
 
subject: About convert datetype 'DATETIME' From SQL (access 2000)into JAVA
 
Similar Threads
Date format
Date Format
Convert Datetype from Access database to Java 'DATETIME'
Date format
How can convert DATETIME type to JAVA date type?