title: MySQL query correct syntax is not working in JdbcTemplate
body: <p>I'm using <code>LIKE</code> keyword to query form a table with single search parameter. When I run the following sql statement in MySQL Workbench, it's working properly as expected.</p>
  
  <pre><code>SET @search = 'B'; 
  SELECT T.*,D.divisionname 
  FROM Township AS T INNER JOIN Division AS D ON T.divisionid=D.divisionid 
  WHERE T.townshipcode LIKE CONCAT('%', @search, '%') OR 
  T.townshipname LIKE CONCAT('%', @search, '%') OR 
  D.divisionname LIKE CONCAT('%', @search, '%') 
  ORDER BY T.townshipcode LIMIT 0,10
  </code></pre>
  
  <p>But, when I execute form my java code with <code>JdbcTemplate</code>, I got <code>BadSqlGrammarException</code>. The following is my java code :</p>
  
  <pre><code>public List&lt;Township&gt; getList(Integer pageNumber, Integer pageDisplayLength, String searchParameter) {
      int start = ((pageNumber - 1) * pageDisplayLength);
      String query = "";
      if (null != searchParameter &amp;&amp; !searchParameter.equals("")){
  
          query = "SET @search = '" + searchParameter + "'; " +
                  "SELECT T.*,D.divisionname FROM Township AS T " +
                  "INNER JOIN Division AS D ON T.divisionid=D.divisionid " +
                  "WHERE T.townshipcode LIKE CONCAT('%', @search, '%') OR " +
                  "T.townshipname LIKE CONCAT('%', @search, '%') OR " +
                  "D.divisionname LIKE CONCAT('%', @search, '%') " +
                  "ORDER BY T.townshipcode LIMIT " + start + "," + pageDisplayLength;                     
      }
      else{
          query = "SELECT T.*,D.divisionname FROM Township AS T " +
                 "INNER JOIN Division AS D ON T.divisionid=D.divisionid ORDER BY T.townshipcode LIMIT " + start + "," + pageDisplayLength;
      }
      List&lt;Township&gt; townshipList = getMultiRecords(query);
      return townshipList;
  }
  </code></pre>
  
  <p>And the following is <code>getMultiRecords</code> method for it's base class :</p>
  
  <pre><code>protected List&lt;T&gt; getMultiRecords(String query){
      List&lt;T&gt; listResult = jdbcTemplate.query(query, new RowMapper&lt;T&gt;(){
          @Override 
          public T mapRow(ResultSet rs, int rowNum) throws SQLException {
              T entity = readRecord(rs);
              return entity;
          }
      });
      return listResult;
  }
  </code></pre>
  
  <p>Here is my <code>BadSqlGrammarException</code> details.</p>
  
  <pre><code>Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [SET @search = 'B'; SELECT T.*,D.divisionname FROM Township AS T INNER JOIN Division AS D ON T.divisionid=D.divisionid WHERE T.townshipcode LIKE CONCAT('%', @search, '%') OR T.townshipname LIKE CONCAT('%', @search, '%') OR D.divisionname LIKE CONCAT('%', @search, '%') ORDER BY T.townshipcode LIMIT 0,10]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT T.*,D.divisionname FROM Township AS T INNER JOIN Division AS D ON T.divis' at line 1
  </code></pre>
  
  <p>Please help me to find out what is the problem.</p>