//set.add(res.getString("TABLE_SCHEM"));
}
System.out.println("All the tables associated to current connection are :");
System.out.println(set);
return set;
}
public static boolean isTableExists(String table, Connection con) throws SQLException{
if(listAllTables(con).contains(table.toUpperCase())){
return true;
}else{
return false;
}
}
public static HashSet
DatabaseMetaData meta = con.getMetaData();
ResultSet res = meta.getSchemas(null, null);
HashSet
while (res.next()) {
}
System.out.println("All the schemas associated to current connection are :");
System.out.println(set);
return set;
}
public static HashMap
DatabaseMetaData meta = con.getMetaData();
ResultSet res = meta.getTables(null, null, null, new String[]{"TABLE"});
HashMap
while (res.next()) {
map.put(res.getString("TABLE_SCHEM"),res.getString("TABLE_NAME"));
}
System.out.println("All the tables and their corresponding schemas associated to current connection are :");
System.out.println(map);
return map;
}
}
摘自 Gaowen_HAN的专栏