code: public static String isValidSqlWithMessage(Connection con, String sql, List<QueryParameter> parameters) {		
  		try {
  			QueryUtil qu = new QueryUtil(con, DialectUtil.getDialect(con));
  			Map<String, QueryParameter> params = new HashMap<String, QueryParameter>();			
  			for (QueryParameter qp : parameters) {
  				params.put(qp.getName(), qp);
  			}
  			qu.getColumnNames(sql, params);
  		} catch (Exception ex) {
  			LOG.error(ex.getMessage(), ex);
  			return ex.getMessage();
  		}
  		return null;
  	}
docs: Test if sql with parameters is valid
  
  @param con database connection
  @param sql sql
  @return return message error if sql is not valid, null otherwise