Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Date conversions from java to SQL

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from code I need to convert the date and time present in String to a sql date
the code is working fine and values are inserting into database...but when I query in database for the time that is present in date object which was inserted by using below code it is showing only
 
Marshal
Posts: 25674
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two questions:

1. What is the type of the column in the database where you put that date?

2. Is there a reason why you use a java.sql.Date object and try to put data containing both date and time in it? I would have thought a java.sql.Timestamp object would be better. However it all depends on the type of the database column.
 
ashok movva
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:Two questions:

1. What is the type of the column in the database where you put that date?

2. Is there a reason why you use a java.sql.Date object and try to put data containing both date and time in it? I would have thought a java.sql.Timestamp object would be better. However it all depends on the type of the database column.



1.type of column in database is Date

paul clapham i will try using timestamp, if there is any problem i will get back......thnq
 
Rancher
Posts: 4614
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the query you use to read that Date value out?
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic