日期:2014-05-20 浏览次数:20802 次
public static Set getForeignKeyColumns(Connection c, String catalog, String schema, String table) throws SQLException { DatabaseMetaData dmd = c.getMetaData(); ResultSet rs = null; HashSet columns = new HashSet(); try { rs = dmd.getImportedKeys(catalog, schema, table); while (rs.next()) { columns.add(rs.getString(8)); } }catch(Exception e){ e.printStackTrace(); } finally { if (rs != null) rs.close(); return columns; } }