This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes java.sql.Date and Oracle. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.Date and Oracle." Watch "java.sql.Date and Oracle." New topic
Author

java.sql.Date and Oracle.

Alok Pota
Ranch Hand

Joined: Mar 07, 2001
Posts: 185
I need to able to insert date & time values in a DATE column of an Oracle table.
The following code
java.util.Date utilDate = new java.util.Date();
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
stmt.setDate(1, sqlDate);
sets the date in the column alright but the TIME is missing.
I need the value to be 8/31/2001 2:13:01 PM and not just
8/31/2001.
I can't change the table columns as they are fixed.
How do I go about inserting a date with its time in an Oracle
DATE column from the Java layer? (Note: I don't want to use the Oracle sysdate() function)
Yogen Vadnere
Ranch Hand

Joined: Sep 20, 2001
Posts: 58
Plz try following and let me know..
cst.setTimestamp(3, new Timestamp(System.currentTimeMillis()));


Yogen Vadnere
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.Date and Oracle.
 
Similar Threads
preparedStatement.setDate and java.util.Date
util.Date to sql.Date
Converting From String to java.sql.Date
How do I set a sql Date object to null using JDBC
Updating Date