Le getSchemas()
la méthode DatabaseMetaData est évidente mais avec MySQL, vous devez utiliser getCatalogs()
http://download .oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getSchemas() http://télécharger .oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getCatalogs()
Exemple :
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") );
}