Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Date conversions from java to SQL  RSS feed

 
ashok movva
Greenhorn
Posts: 16
  • 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
 
Paul Clapham
Sheriff
Posts: 22681
43
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: 16
  • 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
 
Dave Tolls
Ranch Foreman
Posts: 2996
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the query you use to read that Date value out?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!