Well, if your RDBMS is SQL Server I'd always say looks at DTS before starting to write your own version of it.
That being said, you have a number of routes to possibly try.
JDBC has the javax.sql.DatabaseMetaData interface, full of useful methods to discover information about a database object. Alternatively you might consider an ORM technology, such as Hibernate, which removes some of the nuts-and-bolts programming.