*
The moose likes JDBC and the fly likes Different  ways of assigning table name dynamically into the code....? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Different  ways of assigning table name dynamically into the code....?" Watch "Different  ways of assigning table name dynamically into the code....?" New topic
Author

Different ways of assigning table name dynamically into the code....?

santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
Dear all

I had made one small appication in that i want to assign the table name in the queries i had written now im using hard coded i want to get it by dynamically one way i know that through properties files . and another way is that i can use java class's . so please tell me the other way's and which one will be more suitable (like wat we are assigning driver Name,URL username ,Password through server.xml and web.xml (JNDI)) so please tell like this so that when i change in server files it should get reflected


Creativity is nothing but Breaking Rules
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

Unless you're using Object-Relational mapping tools, its pretty hard not to hard-code SQL statements and most solutions that get around this do so in an un-manageable way. For example, you can have every query in a single properties file and/or attached to a stored procedure but the long term maintenance tends to lead to out-of-date and confusing code. Why do you want the table names to be dynamic? In practice, database changes are significantly less common than code changes.


My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Different ways of assigning table name dynamically into the code....?
 
Similar Threads
retrieve data from database
how to assign value to java bean using <jsp:setProperty> in jsp?
dynamically change the width of table cell(td) thorough java script
How to update rows in Table layout
creating a database table