• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get fields and types for tables

 
syd kahn
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My goal is to write a utility like i use in my ASP database work.

given a table name in a database it auto generates a class wrapper for the table that knows how to insert/update/delete from the table.

before i go and re-invent the wheel, is there one out there that i can customize to my needs.

If not, is there some resource that outlines what classes i need to use to get at the tables rows and types? With that i can generate the set / get / select statements...

Seems simple enough... doesn't it?
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Syd,

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

HTH.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic