Bug #44863 getVersionColumns does not return resultset as per JDBC API specifications
Submitted: 14 May 10:58 Modified: 26 May 12:50
Reporter: Vivekanand Bachche
Status: Closed
Category:Connector/J Severity:S3 (Non-critical)
Version:5.1.7 OS:Microsoft Windows
Assigned to: Target Version:
Triage: Needs Triage: D4 (Minor)

[14 May 10:58] Vivekanand Bachche
Description:
Result set returned by getVersionColumns (Database metadata) does not have format as
defined in the specifications. Third 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.getVersionColumns (null, null, null);

    ResultSetMetaData rsmd = rs.getMetaData();             
    System.out.println("Column Name is : " + rsmd.getColumnName(3));	// It is
“DATA_TYPE”
    System.out.println("Column Type is : " + rsmd.getColumnType(3));	// Expected type is
Integer i.e. 4
}
[14 May 12:41] Vivekanand Bachche
Logical cause and fix looks to be simialar for following bugs-
44791
44862
44863
44865
44867
44868
44869
[14 May 13:09] Vivekanand Bachche
Please exclude 44791 from the list in my previous comment.
[14 May 18:52] Valeriy Kravchuk
Thank you for the problem report.
[22 May 22:54] Mark Matthews
Fixed, see http://bazaar.launchpad.net/~mark-mysql/connectorj/5.1/revision/793
[26 May 12:50] Tony Bedford
An entry has been added to the 5.1.8 changelog:

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