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

[14 May 2009 9:12] Vivekanand Bachche
Description:
Result set returned by getColumns (Database metadata) does not have format as defined in the specifications. Fifth 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() {

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

               DatabaseMetaData metadata = connection.getMetaData();
    ResultSet rs = metadata.getColumns(null, null, null, null);

    ResultSetMetaData rsmd = rs.getMetaData();             
    System.out.println("Column Name is : " + rsmd.getColumnName(5));	// It is “DATA_TYPE”
    System.out.println("Column Type is : " + rsmd.getColumnType(5));	// Expected type here is Integer i.e. 4 
}
[14 May 2009 10:41] Vivekanand Bachche
Logical cause and fix looks to be simialar for following bugs-
44791
44862
44863
44865
44867
44868
44869
[14 May 2009 11:10] Vivekanand Bachche
Please exclude 44791 from the list in my previous comment.
[14 May 2009 16:51] 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:51] Tony Bedford
An entry was added to the 5.1.8 changelog:

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