Hi All,
I have a Spring 2.0 project. For data access good old
JDBC code is used i.e specifying SQL query in a
String variable (the code was written some time back so cant change that part).
There are 2 data bases of different vendors and they have the same tables, at one time though only one will be in use. The problem is column name of a table in one DB is a reserved
word in other DB. To get over this in other DB the column name has been changed.
Here in lies my problem, as if there is switching from DB1 to DB2 the SQL query will have to change so as to reflect the correct column name.
The two ways that i have figured out around this is as follows:
1. Set an environment variable in the Websphere admin console. This would hold the value of the column name. In case of DB switching just change this variable to a appropriate value. The
java code will say
Hence no change in application code.
2. Use DatabaseMetadata interface's getColumns() method.
Is there any other way to do this, especially in context of existing Spring classes(not JDBCTemplate etc) or some other way.
I would really appreciate any help on this.
Thanks,
Akshay