导入的类型无法解析为类型
Imported type cannot be resolved to a type
我似乎在使用 Eclipse 时遇到了一个非常奇怪的问题。随机我的代码会中断产生这个错误:
java.lang.Error: Unresolved compilation problems:
ResultSet cannot be resolved to a type
The method sqlResult(String, ArrayList<Object>) from the type SQLFactory refers to the missing type ResultSet
SQLFactory.java:
...
import com.mysql.jdbc.ResultSet;
public class SQLFactory {
private Connection conn;
private static String dbName = "";
private static String url = "jdbc:mysql://localhost:3306/eecoursework?characterEncoding=utf8" + dbName;
private static String username = "root";
private static String password = "...";
public SQLFactory() {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection(url, username, password);
} catch (Exception e) {
e.printStackTrace();
}
}
public ResultSet sqlResult(String SQL, ArrayList<Object> paramVals) {
try {
PreparedStatement statement = conn.prepareStatement(SQL);
...
paramVals 只是 strings/ints
的列表
将导入从 .ResultSet 更改为 .*,保存和还原有时会修复它,但并非总是或永久。关闭 eclipse,清理项目,清理 Tomcat 有时也会修复它,但问题与之前相同。
这件事真让我抓狂,我在 Eclipse 上遇到了很多问题,Tomcat 不合作,花费更多的时间让 IDE 工作而不是生产,这非常令人沮丧代码
发生错误时在 Eclipse 中清理项目修复了此问题
我似乎在使用 Eclipse 时遇到了一个非常奇怪的问题。随机我的代码会中断产生这个错误:
java.lang.Error: Unresolved compilation problems:
ResultSet cannot be resolved to a type
The method sqlResult(String, ArrayList<Object>) from the type SQLFactory refers to the missing type ResultSet
SQLFactory.java:
...
import com.mysql.jdbc.ResultSet;
public class SQLFactory {
private Connection conn;
private static String dbName = "";
private static String url = "jdbc:mysql://localhost:3306/eecoursework?characterEncoding=utf8" + dbName;
private static String username = "root";
private static String password = "...";
public SQLFactory() {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection(url, username, password);
} catch (Exception e) {
e.printStackTrace();
}
}
public ResultSet sqlResult(String SQL, ArrayList<Object> paramVals) {
try {
PreparedStatement statement = conn.prepareStatement(SQL);
...
paramVals 只是 strings/ints
的列表将导入从 .ResultSet 更改为 .*,保存和还原有时会修复它,但并非总是或永久。关闭 eclipse,清理项目,清理 Tomcat 有时也会修复它,但问题与之前相同。
这件事真让我抓狂,我在 Eclipse 上遇到了很多问题,Tomcat 不合作,花费更多的时间让 IDE 工作而不是生产,这非常令人沮丧代码
发生错误时在 Eclipse 中清理项目修复了此问题