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:
getJdbcTemplate().queryForObject("SELECT CONVERT(VARCHAR(255), NEWID())", String.class);
where getJdbcTemplate() returns initialized JdbcTemplate object, the IDE has proper syntax highlighting for the SQL statement (you can see it on the snippet bellow):
.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;}
<span class="code">getJdbcTemplate().queryForObject("<span class="db-stmt"><span class="db-keyword">SELECT CONVERT</span>(<span class="db-keyword">VARCHAR</span>(<span class="db-number">255</span>), NEWID())</span>", String.<span class="java-class">class</span>);</span>
However, when I use another method, created by me:
protected String queryForString(String sql, Object... args) {
try {
return getJdbcTemplate().queryForObject(sql, String.class, args);
}
catch (RuntimeException e) {
return null;
}
}
for the same query:
queryForString("SELECT CONVERT(VARCHAR(255), NEWID())");
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?