Most of this information can be queried through DatabaseMetaData class, which you can retrieve using a Connection class's getMetaData() method.
Other more complex, but also more powerful solutions exist. If you haven't already done so, have a look at Hibernate. Another project you may find intersting is Trails
The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny GillTweets
Joined: Jan 29, 2003
I did a school project that reads DDL and builds an internal model of the database. From there it inserts random data of the correct type with a variety of strategies for handling foreign keys. One could certainly take the parser and model and write something to generate data accessors for CRUD. Let me know if you'd like to see it all.
At work I use a framework that takes the model from XML (exported from Rose) and uses XSL to generate the Java. Pretty slick if you can tolerate XSL.
But, as mentioned above, this is a big job and it's already been done. I'd see if one of the available packages can do it before I wrote my own.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi