I wanted to retrive all the table name from a specific database. I tried the follwowing 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();
}
but it is giving nullpointer exception.