Good day. I myself am not a JAVA-developer, but I had to delve into the work of JAVA with a SQL-server. I installed IntelliJ IDEA, created a project, everything is as it should. Here is the code:

package test; import com.mysql.fabric.jdbc.FabricMySQLDriver; import java.sql.*; public class Main { private static final String URL = "jdbc:mysql://localhost:3306/mydb_test"; private static final String USERNAME = "root"; private static final String PASSWORD = "root"; public static void main(String[] args){ try { Driver driver = new FabricMySQLDriver(); DriverManager.registerDriver(driver); } catch (SQLException e) { e.printStackTrace(); } try(Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD); Statement statement = connection.createStatement() ) { System.out.println(connection.isClosed()); } catch (SQLException e) { e.printStackTrace(); } } } } 

I start to compile, an incomprehensible error pops up

Error: java: invalid flag -release

enter image description here

Help me figure out what's wrong.

  • The case is most likely in the version of the idea that can not work correctly with the new version of Java. You need a version of the idea that supports Java 9 (if there is one at all). - Roman C
  • one
    Then, maybe, it is more reasonable to connect 7 version of JAVA to it? - Setplus

1 answer 1

Older versions of IDEA do not work well with JDK version 9.

Upgrade to IntelliJ IDEA 2017.2.5