Just heard about 'SQL Hints' to optimize query's result or processing time at typing SQL queries. I have found plenty of information about how to implement this concept into Hibernate, but nothing about how to use it with plain Java code. Can anyone help me with this?
We are using the following code:
String value = "someValueToUseAsFilter";
String query = "SELECT /*+ opt_param('_optimizer_cost_model','io') opt_param('optimizer_index_cost_adj',20) opt_param('optimizer_index_caching',65) PARALLEL(4)*/ "+
" T.field AS table_field "+
" FROM table T "+
" WHERE T.field = ? "+
"/";
ResultSet rs = null;
PreparedStatement stmt = null;
try {
stmt = this.connection.prepareStatement(query);
stmt.setQueryTimeout(this.timeout);
stmt.setString(1, value);
rs = stmt.executeQuery();
}
catch (Exception e){
e.printStackTrace();
}
Next, eclipse is throwing the following exception:
java.sql.SQLSyntaxErrorException: ORA-00936: missing expression
The query has been tested and if launched directly against the database it works fine. But keeps returning this error when using it on code. Can anyone explain me if this is even possible? If so, How can I use it in this context?
Thank you.