###前提・実現したいこと
JDBCを使用しJavaからpostgreSQLへの接続
###発生している問題・エラーメッセージ
HTTPステータス 500 - org.postgresql.util.PSQLException: サーバはパスワード・ベースの認証を要求しましたが、いかなるパスワードも提供されませんでした。
###該当のソースコード
public static ResultSet doSQL(String sql) throws Exception {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try { Class.forName("org.postgresql.Driver"); conn = DriverManager.getConnection( "jdbc:postgresql://localhost:5432/postgres,postgres,password"); stmt = conn.createStatement(); rs = stmt.executeQuery(sql); } finally { if (rs != null) rs.close(); if (stmt != null) stmt.close(); if (conn != null) conn.close(); } return rs;
###試したこと
pg_hba.confの設定は
IPv4 local connections:
host all all 127.0.0.1/32 md5
となっていることを確認
"md5"を"trust"に変更し実施したところ下記エラーメッセージの出力
HTTPステータス 500 - org.postgresql.util.PSQLException: FATAL: データベース"postgres,postgres,password"は存在しません (pgjdbc: autodetected server-encoding to be MS932, if the message is not readable, please check database logs and/or host, port, dbname, user, password, pg_hba.conf)
localhost:5432/postgres,postgres,password
部分の設定内容はpsqlにて確認
Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Javaを初めたばかりで分からないことが多いですが、ご回答お願いします。
回答1件
あなたの回答
tips
プレビュー