Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL validation in IntelliJ IDEA: How to turn it off?

Does anyone know how I turn off the SQL validation in Intellij IDEA 9?

We often have more than one connection to a different type of database within one class. IntelliJ only allows one SQL dialect per class, resulting in what IntelliJ thinks are errors, so litters my code with red lines.

Ideally I'd just like to turn the errors off completely, as they are distracting and not actually real errors.

like image 691
Noel M Avatar asked Jul 08 '10 09:07

Noel M


3 Answers

Settings > Inspections. Unselect 'SQL'. Alternatively you can place your cursor on the error and press alt+enter. One of the options will be 'Disable Inspection'.

like image 152
Craig Wohlfeil Avatar answered Sep 23 '22 08:09

Craig Wohlfeil


You could use a comment language= before the statement, i.E.

//language=MySQL
String stmt1 = "INSERT INTO a (b) values(?)";
//language=Oracle
String stmt2 = "SELECT SYSDATE FROM dual";

See https://www.jetbrains.com/idea/help/using-language-injections.html

like image 26
Swen Thümmler Avatar answered Sep 21 '22 08:09

Swen Thümmler


You can alternatively turn off the specific inspection that is bothering you. No need to turn off all SQL support (e.g. auto-complete hints are nice).

To do this, you can go to Settings --> Editor --> Inspections --> SQL and uncheck the ones you don't want. For instance, I just disabled "No data sources configured" and "Unresolved reference".

In IntelliJ Ultimate 2019.2, this looks like this:

IntelliJ SQL Inspections

like image 33
Clint Eastwood Avatar answered Sep 25 '22 08:09

Clint Eastwood