title: separating SQL from JAVA code
body: <p><strong>Question</strong></p>
  
  <p>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. </p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p><strong>Searched Sources</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/1544335/java-storing-sql-statements-in-an-external-file">Java - Storing SQL statements in an external file</a></p>
  
  <p><a href="https://stackoverflow.com/questions/10872919/separating-sql-from-the-java-code">Separating SQL from the Java Code</a></p>
  
  <p><strong>Update</strong></p>
  
  <p>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. :)</p>
  
  <p>Sometimes I just like to research new approches to certain problems.</p>