JConnector 3.0 and DATETIME

JConnector 3.0 and DATETIME

am 24.03.2003 08:17:56 von Brandon Goodin

I have noticed there is a bad design in JConnector 3.0-.

Storing values into the DATETIME field requires that java type be of type
java.sql.Timestamp in order for the whole DATE and TIME to be preserved.
Otherwise if I try to store a DATETIME as java type java.util.Date it zeros
the time out (hh:mm:ss) and store only the Date.

This is a bad feature/design considering that many database apps use a
TranferObject pattern. This pattern uses a JavaBean to transfer neccessary
values to and from the database layer. It is BAD design to have to include a
sql specific java type (java.sql.Timestamp) in a transfer object in order to
accomodate JConnectors bad design.

The problem is further compounded in various Object-Relational-Mapping tools
that require all the typing be base typing. In these cases the ability to
create a Timestamp from the Date is not possible. Therefore annoying
limitations are introduced.

The Date object contains all the neccessary information to store in a
Timestamp. Why hasn't this been fixed yet. It has been like this for WAY WAY
WAY too long.

Brandon Goodin
Phase Web and Multimedia
PO Box 85
Whitefish MT 59937
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws



--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org

Re: JConnector 3.0 and DATETIME

am 24.03.2003 14:41:47 von Mark Matthews

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Brandon Goodin wrote:
> I have noticed there is a bad design in JConnector 3.0-.
>
> Storing values into the DATETIME field requires that java type be of type
> java.sql.Timestamp in order for the whole DATE and TIME to be preserved.
> Otherwise if I try to store a DATETIME as java type java.util.Date it zeros
> the time out (hh:mm:ss) and store only the Date.
>
> This is a bad feature/design considering that many database apps use a
> TranferObject pattern. This pattern uses a JavaBean to transfer neccessary
> values to and from the database layer. It is BAD design to have to include a
> sql specific java type (java.sql.Timestamp) in a transfer object in order to
> accomodate JConnectors bad design.
>
> The problem is further compounded in various Object-Relational-Mapping tools
> that require all the typing be base typing. In these cases the ability to
> create a Timestamp from the Date is not possible. Therefore annoying
> limitations are introduced.
>
> The Date object contains all the neccessary information to store in a
> Timestamp. Why hasn't this been fixed yet. It has been like this for WAY WAY
> WAY too long.

It hasn't been fixed, because no one has found issue with it before. Do
you know of other JDBC drivers for other databases that work this way?
If so, please let me know, and I will consider changing the behavior, or
at least letting you pass a flag to do it.

The way Connector/J works now is JDBC compliant. The change you propose
is not. There is no mapping given in the JDBC spec for the
java.util.Date type. If you look at page 30 of the JDBC spec, you will
find Sun's reasons for not using java.util.Date with SQL. If you look
further into the JDBC apidocs, you notice that java.sql.Date
_does_not_store_ time information, and the java.sql.Date class actually
does the 'zeroing' of the date/hour (from
http://java.sun.com/j2se/1.4/docs/api/java/sql/Date.html):

"To conform with the definition of SQL DATE, the millisecond values
wrapped by a java.sql.Date instance must be 'normalized' by setting the
hours, minutes, seconds, and milliseconds to zero in the particular time
zone with which the instance is associated."


Thanks!

-Mark


- --
MySQL 2003 Users Conference -> http://www.mysql.com/events/uc2003/

For technical support contracts, visit https://order.mysql.com/?ref=mmma

__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mark Matthews
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java
/_/ /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA
<___/ www.mysql.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.1.90 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+fwsgtvXNTca6JD8RApD5AJ9Q8zbZkjxjF3uQ7fFmCJnNlA7N0QCg x5dO
0/SW0OaIMfmegb0uuMGmzEY=
=HDC4
-----END PGP SIGNATURE-----


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org