How to get tables and views using DatabaseMetaData in JDBC <p>I am practicing JDBC and trying to get the list of table names and view names with the help of <code>DatabaseMetaData</code> interface.</p> <p>Here is a sample code:</p> <pre><code>public class Sample { public static void main(String[] args) throws SQLException { try(Connection con = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:xe", "test", "test")){ DatabaseMetaData dbmd = con.getMetaData(); ResultSet rs = dbmd.getTables(null, null, null, new String[]{"TABLE"}); while(rs.next()){ System.out.println(rs.getString(1)); System.out.println(rs.getString(2)); System.out.println(rs.getString(3)); System.out.println(rs.getString(4)); } } } } </code></pre> <p>I was just trying to get the tables which are available for the login user "test" which I was using for creating DB connection, but in the output I am seeing so many records, so how I just get the table names and view names?</p>