Bug #77216 DatabaseMetaData.getSchemas() always returns empty ResultSet
Submitted: 1 Jun 2015 23:38 Modified: 2 Jun 2015 10:59
Reporter: Michael Hobbs Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.6 OS:Any
Assigned to: CPU Architecture:Any
Tags: DatabaseMetaData, jdbc

[1 Jun 2015 23:38] Michael Hobbs
Description:
DatabaseMetaData.getSchemas() always returns empty ResultSet.

Expected non-empty ResultSet based on: http://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getSchemas()

http://stackoverflow.com/questions/30567224/java-databasemetadata-getschemas-returns-empty...

How to repeat:
DatabaseMetaData dmd = this.connection.getMetaData();
ResultSet rs = dmd.getSchemas();
while (rs.next()){
    System.out.println(rs.getString(1));
}

Suggested fix:
For example getSchemas() could:

return this.connection.prepareStatement("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA;").executeQuery();
[2 Jun 2015 10:59] Filipe Silva
Hi Michael,

Thank you for this bug report.

Although not a direct duplication of Bug#23304, the discussion that took place there applies here too. Basically it can be summed to:
«Because of legacy issues (going all the way back to the ODBC driver, and ease of porting from other ODBC databases), our drivers do not support the concept of schemas. Databases are mapped to catalogs in both our JDBC and ODBC drivers.»

Marked as duplicate of Bug#23304.