I didn't understand why u r using (new java,util.Date()) there.
U can just use new java.sql.Date()
----- Original Message -----
From: "Hans Liebenberg" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 19, 2001 6:11 PM
Subject: PreparedStatment and Dates
> Hi,
>
> I have run into a problem that doesn;t make much sense, I think I'm
> obvioulsy being a bit stupid.
> I am accessing a SQL server 7.0 database storing and retrieving datetime
> field types.
>
> I want to insert the current date AND time into the field.
>
> Lets say my code was
>
> stmt = conn.prepareStatement("INSERT INTO
myTable(?,?,?)");
> stmt.setString(1, "blah");
> stmt.setDate(2, new java.sql.Date(new
> java.util.Date().getTime()));
> stmt.setString(3, "blah");
> stmt.executeUpdate();
>
> This only inserts the Date into the field i.e the resulting row looks like
> "blah" , "19/07/2001 00:00"
>
> so then I try...
>
> stmt = conn.prepareStatement("INSERT INTO
myTable(?,?,?)");
> stmt.setString(1, "blah");
> stmt.setTime(2, new java.sql.Time(new
> java.util.Date().getTime()));
> stmt.setString(3, "blah");
> stmt.executeUpdate();
>
> This only inserts the Time into the field i.e the resulting row looks like
> "blah" , "01/01/1900 13:59"
>
> What method can I use witha prepared statement?
> Or is it perhaps my JDBC river that is buggared? Where can I can a good
SQL
> Server jdbc driver from?
>
> Thanks
> Hans
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html