Saturday, 24 August 2013

Designing a query class for database

Designing a query class for database

I am writing an application that interacts with databases. I want to use
PreparedStatement to execute the query, but the number of queries that I
have to do is high and may increase in future.
I only know to write a function for a particular query to execute it and
cannot think of a better way to do it.
For example queries can be:
SELECT *
FROM TABLE_NAME
WHERE TABLE_NAME.ATTRIBUTE_NAME = ?
and
SELECT *
FROM TABLE_NAME
WHERE TABLE_NAME.ATTRIBUTE_NAME = ?
AND TABLE_NAME.ATTRIBUTE_NAME1 = ?
and I will have to write an independent function to execute both(an
example of how to do it for one query), but I know that this isn't a
modular way to do this.
Is there better way to do it?

No comments:

Post a Comment