Question
In some projects of mine I used SQL code, this is nothing special. But I was rethinking this strategy. I searched SO for something to separate my code and SQL statements.
I found one answer which I liked, Collecting all your SQL statements in a properties file. I think it's nice and clean. But what if you want to insert variables.
Another solution I found was the use of DAO objects. I you for instance create a MYSQLFactory class with the following methods: addCustomer(Customer customer), deleteCustomer(int CustomerId) etc. You would have centralized your SQL code. Still wouldn't call it separated.
Is there a better way to do this without using ORM's like Hibernate. The more I read, the more I become convinced that there isn't a neat way of doing this with JAVA.
Searched Sources
Java - Storing SQL statements in an external file
Separating SQL from the Java Code
Update
Thanks for the great responses. I was just curious about this. @Gilbert, I think it's a great solution, As a matter of fact I already used your solution at one time, so thanks for that. :)
Sometimes I just like to research new approches to certain problems.