Here you can find the source of getDBUsers(DatabaseMetaData metaData)
public static String[] getDBUsers(DatabaseMetaData metaData) 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.ArrayList; import java.util.List; public class Main { public static String[] getDBUsers(Connection conn) throws SQLException { return getDBUsers(conn.getMetaData()); }/*w ww . ja v a2 s . c om*/ public static String[] getDBUsers(DatabaseMetaData metaData) throws SQLException { ResultSet rs = metaData.getSchemas(); List<String> users = new ArrayList<String>(); try { while (rs.next()) { users.add(rs.getString("TABLE_SCHEM")); } } finally { rs.close(); } String result[] = new String[users.size()]; users.toArray(result); return result; } }