Let's think about moving sql out of java in order to make queries easier to read and allow for alternate queries according to database
A good first step I think would be to use QueryLoader and put the sql in a properties file. Maybe we could put our own query loader in org-srs-datahandling-common.
http://commons.apache.org/dbutils/apidocs/org/apache/commons/dbutils/QueryLoader.html
Example of use:
sql.properties
sqlstatement=\ select someid, someproperty from sometable where someid = ? sqlstatementtrue=\ select someid from sometable\ where someproperty = ?
MyClass.java
final Map queryMap; public MyClass(){ queryMap = QueryLoader.instance().load("/org/srs/project/sql.properties"); } void someMethod(){ Connection connection = null; PreparedStatement stmt = null; ResultSet rs = null; try{ connection = Utils.getConnection(); stmt = connection.prepareStatement(queryMap.get("sqlstatement")); stmt.setLong(1,1234); rs = stmt.executeQuery(); if(rs.next()){ System.out.println(rs.getString(2); } catch (Exception e){ System.out.println("Some error happened"); } };