• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

get fields and types for tables

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic