| Bug #23303 | ResultSet from getSchemas() doesn't contain a TABLE_CATALOG column | ||
|---|---|---|---|
| Submitted: | 15 Oct 2006 9:13 | Modified: | 22 Feb 2007 11:21 |
| Reporter: | Alexander Hristov (Candidate Quality Contributor) | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / J | Severity: | S2 (Serious) |
| Version: | 5.0.3 | OS: | Any (Any) |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | database metadata, getSchemas, JDBC 3.0, TABLE_CATALOG | ||
[22 Oct 2006 14:41]
Tonci Grgin
Hi Alexander and thanks for your problem report. Verified as described by reporter.
[10 Jan 2007 22:22]
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/17894
[22 Feb 2007 11:21]
MC Brown
A note has been added to the 5.0.5 changelog.

Description: In JDBC 3.0, the getSchemas() method was modified to include a TABLE_CATALOG column in the resultset, and the current implementation does not include that column. How to repeat: public class Test { public static void main(String[] args) throws Exception { Class.forName("com.mysql.jdbc.Driver"); Properties p = new Properties(); p.setProperty("user","..."); p.setProperty("password","..."); p.setProperty("useInformationSchema","true"); Connection con = (Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/test",p); DatabaseMetaData dbmt = con.getMetaData(); ResultSet rs = dbmt.getSchemas(); ResultSetMetaData rsmt = rs.getMetaData(); for (int i = 1; i <= rsmt.getColumnCount(); i++) { System.out.println("Col #"+i+" => "+ rsmt.getColumnName(i)); } } } Suggested fix: Could be quick-fixed in com.mysql.jdbc.DatabaseMetaData by modifying the getSchemas method to: public java.sql.ResultSet getSchemas() throws SQLException { Field[] fields = new Field[2]; fields[0] = new Field("", "TABLE_SCHEM", java.sql.Types.CHAR, 0); fields[1] = new Field("", "TABLE_CATALOG", java.sql.Types.CHAR, 0); ArrayList tuples = new ArrayList(); java.sql.ResultSet results = buildResultSet(fields, tuples); return results; } but see the bug titled ("Inconsistency between getSchemas and INFORMATION_SCHEMA")