That is the problem.  I changed the mapping for java.util.Date to a JDBC
type of TIMESTAMP, which is mapped to a mySQL type of DATETIME.  I am now
getting the desired results.

Thanks,
Michael


-----Original Message-----
From: Philip Molter [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 31, 2001 10:17 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: java.util.Date, jdbc, and DATETIME


On Wed, Oct 31, 2001 at 09:35:49AM -0500, [EMAIL PROTECTED] wrote:
: This question was asked back in 1999 and wasn't answered, so hopefully
: someone will answer it now.
: 
: I am using JBoss and they provide a JDBC to mySQL type mapping that maps
: java.util.Dates to a jdbc-type of DATE and mySQL type of DATETIME.  Well,
: only the date portion (10-31-2001) is being stored and the time is set to
: 00:00:00.  It is a very simple question, why isn't the time being stored?
I
: am using the MM jdbc driver.  Is it the driver code?

Do something like this:

  statement.setTimestamp( 4, new Timestamp( myDate.getTime() ) );

The JDBC standard is for setDate() to store only DATE information.  To
set the entire timestamp, you need to use setTimestamp, which takes a
java.sql.Timestamp instance.  You can still fetch with getDate( int ),
though.

* Philip Molter
* DataFoundry.net
* http://www.datafoundry.net/
* [EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to