| Bug #25787 | getObject on a java.util.Date returns java.langString (Linux) | ||
|---|---|---|---|
| Submitted: | 23 Jan 2007 16:24 | Modified: | 27 Feb 2007 14:50 |
| Reporter: | A M | ||
| Status: | Closed | ||
| Category: | Connector/J | Severity: | S2 (Serious) |
| Version: | Kernel: 2.6.16.21-0.25-bigsmp | OS: | Linux (Suse Linux ) |
| Assigned to: | Target Version: | ||
| Tags: | jdbc, linux | ||
[23 Jan 2007 19:12]
Mark Matthews
If you want to store something date-time like, you should be using either java.sql.Date or java.sql.Timestamp. If you're trying to serialize an object, the underlying column needs to be a BINARY type ([var]binary or some sort of blob). Since you didn't post your schema, we can't tell if what you're doing should even work at all. Please post the schema of the table you're using.
[23 Jan 2007 19:42]
A M
The field which I'm referring to is a BLOB field.
CREATE TABLE 'TABLE1' ('ROW_ID' INT NOT NULL AUTO_INCREMENT PRIMARY_KEY,
'MY_OBJECT_FIELD'BLOB NULL) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;
[13 Feb 2007 21:25]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/19797
[22 Feb 2007 15:24]
MC Brown
A note has been added to the 5.0.5 changelog.
[27 Feb 2007 14:50]
MC Brown
Confirmed in 5.0.5 changelog.

Description: When I store ajava.util.Date object via JDBC using setObject() method and then try to retrieve it using getObject() method, I get back a java.lang.String Object and not java.util.Date Object as I expected. How to repeat: // Store the date object PreparedStatement ps = conn.prepareStatement("INSERT INTO ... "); ps.setObject(1, new Date()); ps.execute(); // Get the date object PreparedStatement ps = conn.prepareStatement("SELECT * FROM ... "); ResultSet res = ps.executeQuery(); if (res.next) res.getObject("MY_OBJECT_FIELD");