title: How to get all the table name from a specific database using jdbc
body: <p>I wanted to retrive all the table name from a specific database. I tried the follwowing code</p>
  
  <pre><code>try {
          DatabaseMetaData dbmd = connection.getMetaData();
          String[] types = {"TABLE"};
          ResultSet rs = dbmd.getTables(null, null, "%", types);
          while (rs.next()) {
              System.out.println(rs.getString("TABLE_NAME"));
          }
      } catch (SQLException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>but it is giving nullpointer exception.</p>