Try the following
When you use the query like it is coded in MySQLDatabaseMetaData to query the primary keys with getPrimaryKeys()
the wrong information_schema table is queried.
Consider the follwing testcase:
As KEY_SEQ which is the ordinal position of the primary key should be returned 1 and not the column of the primary key. The Sun jdbc implementation uses a own resultset which is build against "show keys from table"
As Seq_in_index which is mapped as KEY_SEQ is returned 1, the right value.
The issue can be solved by using a query against the table KEY_COLUMN_USAGE here as example: