为啥报错这些亮红色的

img


这个为啥不行,为啥报错?就是这些东西,不知道哪里有问题,想问一下怎么办

相关的类 没有导入进来

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

/**
 * @author huazie
 * @version 2.0.0
 * @since 2.0.0
 */

public class Main {

    public static void main(String[] args) throws Exception {

        Class.forName("com.mysql.jdbc.Driver");
        String url = ""; // 你自己的
        String username = "root";
        String password = "1234";

        Connection conn = DriverManager.getConnection(url, username, password);

        String sql = "update student set age=20 where name= ?";

        PreparedStatement statement = conn.prepareStatement(sql);
        statement.setObject(1, "张三");

        int count = statement.executeUpdate();

        if (count == 1) {
            System.out.println("更新成功");
        }

        // 释放资源,先打开的后关闭
        statement.close();
        conn.close();
    }
}

你把你自己原先乱导入的哪些包先删掉

这个是因为你导入了不正确的类,可以看看红色那块类是哪个包名下面的,把包名的类删掉,重新导入正确的