This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC setDate (oracle driver).

 
lvkiran
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a column with "DATE" as datatype ..As part of a batch process I need to insert the start date and time into that (YYYY-MM-DD HH24:MI:SS).
If i use just the Statement and the to_date function in the "values" clause it works ..but this is an existing application using "Prepared Statement" and we're migrating from sybase to oracle. When I am trying to use the setDate function it is just inserting the date part and putting zeros (00:00:00) for time part where as in sybase just the setString was taking care of everything ... Any suggestions please ...
 
Andy Bowes
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried using the setTimestamp() method on the Prepared Statement ?
e.g.
java.util.Date now = new java.util.Date();
ps.setTimestamp( new java.sql.Timestamp(now.getTime()) );
I think that the setDate() method only sets the date portion of the DateTime column.
HTH
 
lvkiran
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Andy .. that works..
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lv,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic