3
package test;

import java.sql.*;

public class Test2 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

    }

}

in the above code. import java.sql.*; contain error that is "The package java.sql is not accessible". Please help me to resolve this error. why java.sql is not accessible.

seenukarthi
  • 8,241
  • 10
  • 47
  • 68
Ali Raza
  • 33
  • 1
  • 1
  • 3

1 Answers1

8

I can see module-info.java file in your screen shot, that means you are using Java 9 and above please add the following in the module-info.java if you want to use modules for your applicatin

requires java.sql;

If you do not want to use modules delete the module-info.java

seenukarthi
  • 8,241
  • 10
  • 47
  • 68
  • 4
    From the screenshot you can see that Java 9 or higher is used, otherwise there would be errors shown for the `module-info.java` file. Deleting the `module-info.java` file is also a solution for this issue when using Java 9 or higher since it's not mandatory to use JPMS. – howlger Dec 13 '20 at 10:37