• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

get fields and types for tables

 
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?
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • 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.
 
(instanceof Sidekick)
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.
 
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic