This week's book giveaway is in the Java in General forum. We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line! See this thread for details.
Different ways of assigning table name dynamically into the code....?
posted 6 years ago
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
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.