-3

I want to import java.sql but it says Package java does not exist I am using Netbeans.

Here is the picture: Screenshot Netbeans

enter image description here

The hint showing in Netbeans is Remove unused import only.

How can I fix this?

Sudhir Ojha
  • 3,247
  • 3
  • 14
  • 24
  • 3
    You either import a specific class (recommended) in the package, or all the classes in the package using `*` (not recommended). – RealSkeptic Mar 04 '20 at 12:15
  • 2
    Does this answer your question? [java.sql import not working](https://stackoverflow.com/questions/43840641/java-sql-import-not-working) – Sudhir Ojha Mar 04 '20 at 12:18

1 Answers1

2

import java.sql is an invalid import.

Either use Ctrl + Shift + I in NetBeans to "Fix Imports" (if you try to use a class in your code that is not imported yet)

Or you import all classes under java.sql package with import java.sql.*;

Or you import the specific class you need, eg import java.sql.Connection;

nullPointer
  • 4,419
  • 1
  • 15
  • 27