Here you can find the source of getCatalogs(Connection c)
public static List getCatalogs(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.LinkedList; import java.util.List; public class Main { public static List getCatalogs(Connection c) throws SQLException { DatabaseMetaData dmd = c.getMetaData(); ResultSet rs = null;// w w w . j a v a 2 s. c o m try { rs = dmd.getCatalogs(); List l = new LinkedList(); while (rs.next()) { l.add(rs.getString(1)); } return l; } finally { if (rs != null) rs.close(); } } }