Java examples for java.sql:Connection
get Table Names From Connection
//package com.java2s; 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 List<String> getTableNamesFromSchema(Connection conn) { List<String> tables = new ArrayList<String>(); try {/*www. j av a2s.c om*/ DatabaseMetaData md = conn.getMetaData(); ResultSet rs = md.getTables(null, null, "%", null); while (rs.next()) { tables.add(rs.getString("TABLE_NAME")); } } catch (SQLException e) { throw new RuntimeException(e); } return tables; } }