rs.close();报错The method close() is undefined for the type Resultset?

跟着视频做个很简单的数据库连接和关闭,结果出现这个错误,网上找了一堆没跟我一样的。。。
错误提示
The method close() is undefined for the type Resultset

代码如下

package com.zkz.magSystem.com;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.mysql.cj.protocol.Resultset;

public class BaseDAO {
    public static Connection getConnection() throws Exception{

        Class.forName("com.mysql.jdbc.Driver");
        return DriverManager.getConnection("jdbc:mysql://localhost:3306/exam","root","12345");
    }

    public static void close(Connection conn,PreparedStatement ps,Resultset rs){
        try {
            if(rs != null)  rs.close();
            if(ps != null)  ps.close();
            if(conn !=null && !conn.isClosed()) conn.close();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
查看全部
qq_35215621
碎骨
2019/05/07 18:21
  • java
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复