Bug #14910 MySQL JDBC 3.1.11 breaks hibernate insert
Submitted: 13 Nov 2005 19:22 Modified: 22 Nov 2005 4:41
Reporter: Leon Widdershoven Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:JDBC 3.1.11, mysql 4.1.12 OS:Linux (Linux)
Assigned to: Mark Matthews CPU Architecture:Any

[13 Nov 2005 19:22] Leon Widdershoven
Description:
The hibernate tutorial does not work correcty with the MySQL jdbc driver 3.1.11.
The driver 3.0.11 does work correctly

After inserting an Event{title=My Event, date=2005-11-13 19:55:21, id=2} with
a query insert into EVENTS (EVENT_DATE, TITLE, EVENT_ID) values (?, ?, ?)
the database contains:
mysql> select * from EVENTS;
+--------------------+---------------------+-------+
| EVENT_ID           | EVENT_DATE          | TITLE |
+--------------------+---------------------+-------+
| 564369423067053312 | 0000-00-00 00:00:00 |
                                                  |
+--------------------+---------------------+-------+
1 row in set (0.00 sec)

whereas with driver 3.0.11 exactly the same program shows:
+----------+---------------------+----------+
| EVENT_ID | EVENT_DATE          | TITLE    |
+----------+---------------------+----------+
|        1 | 2005-11-13 19:54:51 | My Event |
+----------+---------------------+----------+

As the only thing which differs is the mysql-jdbc driver, something must have
changed in between releases.
java version "1.4.2_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_09-b05)
Java HotSpot(TM) Client VM (build 1.4.2_09-b05, mixed mode)

Hibernate version: 3.0.5

How to repeat:
Implement the hibernate tutorial up to and including section 2.2.6 and run it.
http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html
[15 Nov 2005 14:23] Mark Matthews
Is it possible for you to attach the working tutorial you have to this bug as a file? Otherwise it will take some time for us to reconstruct it ourselves, thus delaying the resolution of this bug.
[15 Nov 2005 14:56] Leon Widdershoven
Tutorial 2 from hibernate, generating errors with 3.1.11 connector

Attachment: MySQLHibernate.tgz (application/octet-stream, text), 2.43 KiB.

[16 Nov 2005 21:59] Mark Matthews
I just tested this with 3.1.12, and it stores the value correctly (otoh, 3.1.11 seems to work too).

I've tried your attached files, and am using the following command line to test it:

ant run -Daction=store

Is this correct?
[16 Nov 2005 22:03] Mark Matthews
A few other questions, is the Linux you're running on a Debian derivative? Is the MySQL server binary one from your vendor, or from us? What happens if you add "useServerPrepStmts=false" to your JDBC URL as a configuration parameter?

We've seen some broken compiles of 4.1 and newer of the server on Debian that cause prepared statements to fail in different ways that aren't there when folks use our "official" binaries.
[17 Nov 2005 20:14] Leon Widdershoven
The distribution is Mandriva 2006, and it is the included MySQL 4.1.12
The JDBC driver is directly from the MySQL web site.

With the remark about useServerPrepStmts=false you put the finger on the sore spot. 
With this parameter included, everything works fine. Without it, it fails.

It also seems to duplicate the same key again; you cannot insert without the parameter
twice, it always seems to insert id=564369423067053312 date=0 title=""
[17 Nov 2005 20:19] Mark Matthews
This looks like yet another vendor-compiled binary with broken prepared statements.

Can you try one of our official _server_ binaries of 4.1 from http://dev.mysql.com/downloads/mysql/4.1.html and tell me if that works okay?
[18 Nov 2005 18:30] Leon Widdershoven
I tried the MySQL 4.1.15 stock rpm from the MySQL site.

There are no problems in the combination with both MYSQL JDBC drivers with
this install; it must have been the Mandrive 2006 RPM with does not
correctly support prepared statements,