Here you can find the source of getTablesFromDatabase(Connection conn)
public static List<String> getTablesFromDatabase(Connection conn)
//package com.java2s; //License from project: Open Source 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 List<String> getTablesFromDatabase(Connection conn) { List<String> tables = new ArrayList<>(); String types[] = new String[] { "TABLE", "VIEW" }; DatabaseMetaData md;//w ww.ja va 2 s .com try { md = conn.getMetaData(); ResultSet rs = md.getTables(null, null, "%", types); while (rs.next()) { String tn = rs.getString(3); tables.add(tn); } } catch (SQLException e) { e.printStackTrace(); } return tables; } }