Reputation: 2384
My requirement is to make the sql queries external to my java code so that it can me modified by manual testers. I need some suggestion/help to write the properties file for my utility class. I know how use/load properties file. But I need some idea about about complex sql queries which can be used by my jdbc classes, when the queries modified in future it should have less impact/ no impact on my java code.
In my properties file which is in my classpath
query1=select org_id from organization where PRIMARY-KEY=454545452
query2=select * from organization_address where org_id in
and in my java class
String query1 = Queries.getQuery("query1");
String query2 = Queries.getQuery("query2");
String finalQuery = query2+"("+query1+")";
I need more flexibility either in properties file or in my java class.
Upvotes: 0
Views: 7475
Reputation: 517
Could proceed like this:
this could be your generic select query on basis of primary key
query1=select {0} from {1} where {2} = {3}
Then can at the time of retrieving query you can use like this
property = MessageFormat.format(query1,new String[]{"org_id","organization","PRIMARY-KEY","454545452"});
Similarly you can generalize the queries and set the values in your java code.
It depends on you what level of generalization you want.
Upvotes: 2