"Package not accessible" error trying to import SQL Server JDBC package in project

mrfwxfqh  于 2023-02-28  发布在  SQL Server
关注(0)|答案(2)|浏览(138)

I'm trying to use the SQL Server JDBC package in my Java project. I'm getting a The package com.microsoft.sqlserver.jdbc is not accessible error in my import statement. I've already added the MSSQL JDBC driver to the appropriate classpath (see attached image). I have another project set up exactly the same way that works just fine. The driver used is the same and the import statements match. Here are my import statements:

package Main;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import com.microsoft.sqlserver.jdbc.*;

None of the other import statements throw an error. I am using this driver: mssql-jdbc-7.4.1.jre12.jar . I am also using JDK 13 for both projects.

fnvucqvd

fnvucqvd1#

I deleted module-info.java and this resolved the error.

mmvthczy

mmvthczy2#

Put a string requires java.sql; in the module-info.java file.

相关问题