Here you can find the source of getSchemas(Connection c)
public static Map getSchemas(Connection c) throws SQLException
//package com.java2s; //License from project: Apache License import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; public class Main { public static Map getSchemas(Connection c) throws SQLException { DatabaseMetaData dmd = c.getMetaData(); ResultSet rs = null;/*from w w w . j av a 2 s. co m*/ try { rs = dmd.getSchemas(); Map map = new HashMap(); List l; while (rs.next()) { String schema = rs.getString(1); String catalog = null; if (rs.getMetaData().getColumnCount() > 1) { catalog = rs.getString(2); } ; l = (List) map.get(catalog); if (l == null) { l = new LinkedList(); map.put(catalog, l); } l.add(schema); } return map; } finally { if (rs != null) rs.close(); } } }