ClassNotFoundException jdbc驱动程序postgresql

ClassNotFoundException jdbc驱动程序postgresql,postgresql,jdbc,classnotfoundexception,Postgresql,Jdbc,Classnotfoundexception,因此,我正在编写一个访问数据库的程序,但只要有可能,就会抛出方法Class.forName(“org.postgresql.Driver”);ClassNotFoundException 我已经研究了我能找到的解决这个问题的每一个方法,但没有任何效果 我希望你能帮我做这件事 代码: 此问题意味着您的项目在初始化时没有加载“org.postgresql.Driver”。 如果您使用IntelliJ,则必须使用“项目结构”添加org.postgresql.Driver,它位于右上角的窗口中。 如果您

因此,我正在编写一个访问数据库的程序,但只要有可能,就会抛出方法
Class.forName(“org.postgresql.Driver”);
ClassNotFoundException

我已经研究了我能找到的解决这个问题的每一个方法,但没有任何效果

我希望你能帮我做这件事

代码:


此问题意味着您的项目在初始化时没有加载“org.postgresql.Driver”。 如果您使用IntelliJ,则必须使用“项目结构”添加org.postgresql.Driver,它位于右上角的窗口中。 如果您不使用IDE,我建议您使用IDE

您还可以使用Maven并添加“org.postgresql.Driver”作为项目的需求


再见。

解决方案总是一样的。postgresql驱动程序的jar文件必须添加到运行时类路径中。
public static void editDatabase(String[] values){
        Connection connect = null;
        Statement statement = null;
        ResultSet result = null;
        try {
            Class.forName("org.postgresql.Driver");
            connect = DriverManager.getConnection(values[0],values[1],values[2]);
            statement = connect.createStatement();
            result = statement.executeQuery("select * from Kunde");
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }