Bug #25328 Resultset.getObject on a BIT(64) type returns java.lang.String
| Submitted: | 29 Dec 2006 11:15 | Modified: | 13 Apr 2007 8:37 |
|---|---|---|---|
| Reporter: | Neha Khaitan | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / J | Severity: | S3 (Non-critical) |
| Version: | 3.1.15SVN | OS: | Windows (Windows XP Professional SP2) |
| Assigned to: | CPU Architecture: | Any |
[29 Dec 2006 13:34]
Valeriy Kravchuk
Thank you for a problem report. Please, try to repeat with a newer version, 3.1.14, and inform about the results.
[2 Jan 2007 8:55]
Neha Khaitan
Hi, I tried the same with mysql connector/j 3.1.14. It still throws ClassCastException.
[26 Mar 2007 13:17]
Tonci Grgin
Hi Neha and thanks for your report. According to http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-type-conversions.html we have a bug. Verified as described with attached test case on - MySQL server 5.0.38BK on WinXP Pro SP2 localhost - c/J 3.1.15SVN and JDK 1.5.0_10
[26 Mar 2007 13:18]
Tonci Grgin
Test case
Attachment: TestBug25328.java (text/x-java), 1.94 KiB.
[26 Mar 2007 15:06]
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/22942
[26 Mar 2007 15:13]
Mark Matthews
This is fixed in the 5.0 branch. It is not the class of bug that would make it into the "legacy" release of 3.1.
[13 Apr 2007 8:37]
MC Brown
A note has been added to the 5.0.6 changelog.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.056 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: I am using MySql 5.0.27. Driver : mysql connector/j 3.1.12 ResultSet.getObject() returns a java.lang.String instead of a bytearray. How to repeat: I have a table with the following DDL: create table Binary_Tab (BINARY_VAL BIT(64) NULL); I do the following from a JSP. Connection conn = getConnection();//code omitted for getConnection() String insertString = "insert into Binary_Tab values(null)"; Statement statement = conn.createStatement(); statement.executeUpdate(insertString); byte[] bytearr = new byte[8]; String sbyteval = null; // to get the bytearray value for (int count = 0; count < 8; count++) { sbyteval = Integer.toString(count % 255); bytearr[count] = Byte.parseByte(sbyteval); } String binTabUpdate = "update Binary_Tab set BINARY_VAL=?"; PreparedStatement pstmt = conn.prepareStatement(binTabUpdate); pstmt.setObject(1,bytearr,java.sql.Types.BINARY); pstmt.executeUpdate(); pstmt.close(); String binTabQuery = "Select BINARY_VAL from Binary_Tab"; ResultSet resultSet = statement.executeQuery(binTabQuery); resultSet.next(); Object object = resultSet.getObject(1); System.out.println("resultSet.getObject(1).getClass() = " + object.getClass().getName()); byte[] oRetVal = (byte[]) object; It throws a ClassCastException when tryin to cast object to byte array as it is a java.lang.String object.