IntelliJ IDEA comes with a very cool feature that provides auto completion and inspection for writing SQL statements write inside Java code such as SQL syntax suggestion; table and column names suggestion for the configured datasources in the project.

If somehow the SQL autocomplete feature is not working in IntelliJ IDEA, you can follow the following two steps to fix it.

 

1. Set language reference as SQL

If IntelliJ doesn’t recognize the SQL literal (with SQL keywords are in orange color), place the caret inside the SQL literal and press Alt + Enter to show the available hints:

show hints

Then choose Inject language or reference, and select SQL from the list of languages:

choose sql

The you will see IntelliJ recognizes the String literal as SQL statement, as shown below:

sql statement recognized



Now, if you press Ctrl + Space, you will see the autocomplete for SQL keywords – not for names of tables and columns in the configured data sources. So perform the last step below.

 

2. Set SQL Dialect

Press Shift two times (double Shift) to see the quick search dialog, and type SQL dialects:

search sql dialects

Wait a couple of seconds to see the SQL Dialects Settings and click it. Then in the Settings dialog, choose the appropriate SQL dialect, e.g. MySQL:

choose sql dialect

Click OK, and come back to edit the SQL statement, you should see the auto completion for table names and column names:

sql autocomplete for table names

That’s 2 steps to fix the SQL autocomplete not working issue in IntelliJ IDEA. Enjoy coding!

To see the solution in action, watch this video:

 

Related Articles:


About the Author:

is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.



Add comment

   


Comments 

#1ARAUF2020-12-05 21:04
Are there more examples that are coded in IntelliJ for the upload and download FTP of files using MVC framework?
Quote