标签:style blog http color java io strong div html
获取database所有table名:
(参考:http://stackoverflow.com/questions/2780284/how-to-get-all-table-names-from-a-database )
DatabaseMetaData md = conn.getMetaData(); ResultSet rs = md.getTables(null, null, "%", null); while (rs.next()) { System.out.println(rs.getString(3)); }
原理:Column 3 is the TABLE_NAME
(see documentation of getTables).
获取某table的所有字段名:
(参考:http://java.dzone.com/snippets/listing-schematablecolumn )
DatabaseMetaData meta = conn.getMetaData(); ResultSet resultSet = meta.getColumns(databaseName, null, tableName, "%"); while (resultSet.next()) { System.out.println(esultSet.getString(4)); }
java——mysql——获取所有table名和table字段名。
标签:style blog http color java io strong div html
原文地址:http://www.cnblogs.com/liu-qing/p/3940245.html