Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JDBC and Relational Databases
Setting date to oracle using Prepared Statement
Vasudevan Gopalan
Ranch Hand
Posts: 67
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I am setting date to oracle using prepared statement.I am using the following code
java.util.Date dt = new java.util.Date(); pst.setDate(5,new java.sql.Date(dt.getTime()));
In database it is setting date alone but not the hour,minute and sec.I need to set the date with hour,minute & sec.
Regards
Vasu
[ February 29, 2004: Message edited by: Vasudevan Gopalan ]
Bikramjit Singh Bajwa
Ranch Hand
Posts: 39
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Pass following method in your java.sql.Date constructure
System.currentTimeMillis()
Hope this works
Chakk de
Bikram
Bikramjit Singh Bajwa
Ranch Hand
Posts: 39
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Sorry to tell you one thing more..
may be your database field would be Date type only instead of DateTime or timestamp..
Chakk de
Bikram
Dirk Schreckmann
Sheriff
Posts: 7023
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Moving this to the
JDBC
forum...
[
How To Ask Good Questions
] [
JavaRanch FAQ Wiki
] [
JavaRanch Radio
]
Christopher Zinn
Greenhorn
Posts: 13
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
java.sql.Date will only fill out the date portion;
java.sql.Timestamp will fill in both portions
java.util.Date dt = new java.util.Date(); pst.setTimestamp(5,new java.sql.Timestamp(dt.getTime())); or pst.setTimestamp(5,new java.sql.Timestamp(System.currentTimeMillis());
- Chris
Vasudevan Gopalan
Ranch Hand
Posts: 67
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks Christopher...
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Convert to timestamp yyyy-MM-dd hh:mm:ss a
Converting Textfield to Date field
Date method
What fields does java.util.Date.equals compare?
Slightly confused about Calendar Object
More...