简体   繁体   English

org.postgresql.util.PSQLException:服务器请求基于 SCRAM 的身份验证,但未提供密码

[英]org.postgresql.util.PSQLException: The server requested SCRAM-based authentication, but no password was provided

import java.sql.*;
import java.io.*;

public class prog1 {
    public static void main(String args[]) {
        String dbname = "BD22";
        String dbuser = "postgres";
        String password = "12345";
        String url = "jdbc:postgresql://localhost:5432/" + dbname;

        try {
            BufferedReader in;
            in = new BufferedReader( new InputStreamReader( System.in ));
            System.out.println("Insira um novo passageiro");
            System.out.print(">> Nome: "); String nomePassageiro = in.readLine();
            System.out.print(">> Morada: "); String destinopretendido = in.readLine();
            System.out.println("Nome: " + nomePassageiro + "    Morada: " + destinopretendido);
            Connection c = DriverManager.getConnection(url);
            c.setAutoCommit(false);
            Statement stmt = c.createStatement();
            String sql = "INSERT INTO passageiros(nomeP,destinopretendido) VALUES ('" +
                    nomePassageiro + "','" + destinopretendido + "');";
            stmt.executeUpdate(sql);
            stmt.close();
            c.commit();
            c.close();
            System.out.println("Estudio " + nomePassageiro + " inserido.");
        }
        catch (Exception e) {
            System.err.println( e.getClass().getName()+": "+ e.getMessage() );
            System.exit(0);
        }
    }
}

When I start the code I can write everything, but when the program starts the "phase" in which it should add to the database what was written, the title error appears and when I debug it, it appears: Disconnected from the target VM, address: '127.0.0.1:54160', transport: 'socket' Someone can help me?当我开始编写代码时,我可以编写所有内容,但是当程序开始“阶段”时,它应该将写入的内容添加到数据库中,出现标题错误,当我调试它时,它出现:与目标 VM 断开连接,地址:'127.0.0.1:54160',传输:'socket' 有人可以帮我吗?

I solved the problem by putting on line 18 (which had the command- Connection c = DriverManager.getConnection(url); ) the following command- Connection c = DriverManager.getConnection(url, dbuser, password);我通过在第 18 行(具有命令 - Connection c = DriverManager.getConnection(url); )下面的命令 - Connection c = DriverManager.getConnection(url, dbuser, password); 解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 服务器请求基于 SCRAM 的身份验证,但未提供密码 - The server requested SCRAM-based authentication, but no password was provided HikariPool-1 - 池初始化期间出现异常 - 他的服务器请求基于 SCRAM 的身份验证,但未提供密码 - HikariPool-1 - Exception during pool initialization - he server requested SCRAM-based authentication, but no password was provided PSQLException:服务器请求基于密码的身份验证,但未提供密码 - PSQLException: The server requested password-based authentication, but no password was provided 如何修复 org.postgresql.util.PSQLException:致命:用户密码验证失败 - How to fix org.postgresql.util.PSQLException: FATAL: password authentication failed for user org.postgresql.util.PSQLException: FATAL: 用户 springboot maven 项目的密码验证失败 - org.postgresql.util.PSQLException: FATAL: password authentication failed for user springboot maven project 引起:org.postgresql.util.PSQLException:致命:用户“admin”的密码验证失败 - Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "admin" org.postgresql.util.PSQLException:服务器不支持SSL - org.postgresql.util.PSQLException: The server does not support SSL ClassNotFoundException:org.postgresql.util.PSQLException - ClassNotFoundException: org.postgresql.util.PSQLException org.postgresql.util.PSQLException - 2019 - org.postgresql.util.PSQLException - 2019 org.postgresql.util.PSQLException:错误:“)”处或附近的语法错误 - org.postgresql.util.PSQLException: ERROR: syntax error at or near “)”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM