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.
2条答案
按热度按时间fnvucqvd1#
I deleted
module-info.java
and this resolved the error.mmvthczy2#
Put a string
requires java.sql;
in themodule-info.java
file.