Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just use getDate() on the ResultSet, you'll be fine.
 
Tracy Lee
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had tried before and I tried it again, Unfortunately, it doesn't work.
Thank you anyway.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!