This is only possible if you clearly define which database you are using. Because there are different ways to solve the same in different database.
No, that is not necessary. As Makarand Parab already pointed out, you can do this by looking at the database metadata that you can get by calling the method java.sql.Connection.getMetaData(). Look it up in the API documentation. Class DatabaseMetaData has a method getTables() to get all the tables in the database (that the user with which you logged in into the database has access to).