Bug #44868 getTypeInfo does not return resultset as per JDBC API specifications
Submitted: 14 May 2009 10:05 Modified: 26 May 2009 10:53
Reporter: Vivekanand Bachche Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.7 OS:Windows
Assigned to: CPU Architecture:Any

[14 May 2009 10:05] Vivekanand Bachche
Result set returned by getTypeInfo (Database metadata) does not have format as defined in the specifications. Second column of the result set is expected to be of type ‘int’ where MySQL driver returns it as ‘smallint’.

This can give critical problems with BI tools which perform strict checking before retreiving metadata information.

How to repeat:
public void testMetadata() {

               Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb?user=myself&password=mypassword");

               DatabaseMetaData metadata = connection.getMetaData();
               ResultSet rs = metadata.getTypeInfo();
       ResultSetMetaData rsmd = rs.getMetaData();             
       System.out.println("Column Name is : " + rsmd.getColumnName(2));	// It is “DATA_TYPE”
       System.out.println("Column Type is : " + rsmd.getColumnType(2));	// Expected type here is Integer i.e. 4
[14 May 2009 10:42] Vivekanand Bachche
Logical cause and fix looks to be simialar for following bugs-
[14 May 2009 11:11] Vivekanand Bachche
Please exclude 44791 from the list in my previous comment.
[14 May 2009 16:46] Valeriy Kravchuk
Thank you for the problem report.
[22 May 2009 20:54] Mark Matthews
Fixed, see http://bazaar.launchpad.net/~mark-mysql/connectorj/5.1/revision/793
[26 May 2009 10:53] Tony Bedford
An entry has been added to the 5.1.8 changelog:

The result set returned by getTypeInfo() did not have the format defined in the JDBC API specifications. The second column, DATA_TYPE, of the result set should be of type INTEGER. Connector/J however returns SMALLINT.