getSchemas()
metoden til DatabaseMetaData er den indlysende, men med MySQL skal du bruge getCatalogs()
http://download .oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getSchemas() http://download .oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getCatalogs()
Eksempel:
Class.forName("com.mysql.jdbc.Driver");
// change user and password as you need it
Connection con = DriverManager.getConnection (connectionURL, "user", "password");
ResultSet rs = con.getMetaData().getCatalogs();
while (rs.next()) {
System.out.println("TABLE_CAT = " + rs.getString("TABLE_CAT") );
}