• 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

New To Java - JDBC DataSource Independent Code - design suggestions

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I get a jndi name from the UI based on which I make a connection and create statement.
I have stored the table_name_constant,table name and column_name_constant,column name in a table. Once Connection is obtained
i am creating the two maps as below.

keyvaluekeyvalue
======================================== | =======================================

table_name_constant - Actual Table Name | column_name_constant - Actual Column Name


I am building my SQL query with key passed into SQL

select map1.get(column_name_constant),... from map2.get(table_name_constant) where map1.get(column_name_constant = ?);


I have done the above design to meet the requirement "Add a new data source, no code changes"
but the tables are updated at the database side. It is assumed that the structure of tables will
remain same but the table names and column names must be dynamic.

If I have explained properly, Is there any better solution than this?

Please suggest!
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A much better solution is to use an existing ORM tool (Hibernate, Castor, JDO, OJB, etc.). You might want to have a look at one of those.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic