title: IntelliJ IDEA - Syntax Highlighting of SQL Inside Java Code
body: <p>I am using IntelliJ 13 as an IDE for a project where communication with DB is done via Spring's JDBC Template. When I have code fragments in Java like the following one:</p>
  
  <pre><code>getJdbcTemplate().queryForObject("SELECT CONVERT(VARCHAR(255), NEWID())", String.class);
  </code></pre>
  
  <p>where getJdbcTemplate() returns initialized JdbcTemplate object, the IDE has proper syntax highlighting for the SQL statement (you can see it on the snippet bellow):</p>
  
  <hr>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.code {font-family: Monospace}
  .db-stmt {background: #EDFCED}
  .db-keyword {color: #000080; font-weight: bold;}
  .db-column {color: #7D0C8D; font-weight: bold;}
  .db-number {color: #0000FF;}
  .java-class {color: #39008E; font-weight: bold;}</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;span class="code"&gt;getJdbcTemplate().queryForObject("&lt;span class="db-stmt"&gt;&lt;span class="db-keyword"&gt;SELECT CONVERT&lt;/span&gt;(&lt;span class="db-keyword"&gt;VARCHAR&lt;/span&gt;(&lt;span class="db-number"&gt;255&lt;/span&gt;), NEWID())&lt;/span&gt;", String.&lt;span class="java-class"&gt;class&lt;/span&gt;);&lt;/span&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <hr>
  
  <p>However, when I use another method, created by me:</p>
  
  <pre><code>protected String queryForString(String sql, Object... args) {
      try {
          return getJdbcTemplate().queryForObject(sql, String.class, args);
      }
      catch (RuntimeException e) {
          return null;
      }
  }
  </code></pre>
  
  <p>for the same query:</p>
  
  <pre><code>queryForString("SELECT CONVERT(VARCHAR(255), NEWID())");
  </code></pre>
  
  <p>there is no syntax highlighting of the SQL statement.
  Do you know how to enable syntax highlighting of SQL staments for Java stings that are not arguments of methonds of JdbcTemplate or java.sql interfaces?</p>