I'm familiar with the java.sql.DatabaseMetaData
interface, but I find it quite clunky to use. For example, in order to find out the table names, you have to call getTables
and loop through the returned ResultSet
, using well-known literals as the column names.
Is there an easier way to obtain database metadata?
Take a look at SchemaCrawler (free and open source), which is another API designed for this purpose. Some sample SchemaCrawler code:
http://schemacrawler.sourceforge.net/
It's easily done using DdlUtils: