Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore "cannot resolve query parameter" error in IntelliJ

I have a query:

Date dDateFrom;
...
String sql = "select a  from tblA where timestamp > ?";
ps = this.connection.prepareStatement(sql);
ps.setTimestamp(1, java.sql.Timestamp(dDateFrom.getTime()));

And the IntelliJ IDE warn an Error: cannot resolve query parameter, I believe it's because the column "timestamp", (I know it's a bad name, but it's defined decade ago, I can not change it).

Anyway I can ignore this error?

like image 482
Dundee Avatar asked Apr 20 '15 06:04

Dundee


2 Answers

Navigate over the part of the code where the error is highlighted, hit ALT+ENTER and select Inspection 'Unresolved queries and query parameter' options -> Edit inspection profile settings. This will open settings dialog where you can uncheck this inspection so that future "errors" of this kind will be ignored.

You can also change it directly from Settings. Just search for Unresolved query.

Btw: this inspection is shown as a JPA inspection, but clearly it works for plain JDBC too.

like image 91
Bohuslav Burghardt Avatar answered Oct 16 '22 15:10

Bohuslav Burghardt


You might be able to avoid the warning by quoting the column name with double-quotes, backticks, or brackets. This is the usual SQL mechanism for allowing unusual column names such as spaces or reserved words, and could help IntelliJ parse it better.

String sql = "select a  from tblA where \"timestamp\" > ?";
like image 41
Andrew Janke Avatar answered Oct 16 '22 16:10

Andrew Janke