java – 引起:org.postgresql.util.PSQLException:致命:用户“admin”的密码验证失败

前端之家收集整理的这篇文章主要介绍了java – 引起:org.postgresql.util.PSQLException:致命:用户“admin”的密码验证失败前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

当我尝试使用我的凭据(pgadmin iii – postgres sqltool)连接到我的Postgresql服务器时,它工作正常.当我尝试从我的Java应用程序连接时,我得到以下日志.有点奇怪

org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is org.postgresql.util.PsqlException: FATAL: password authentication Failed for user "admin"
    at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:240)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy8.getCollegeDetails(Unknown Source)
    at com.cts.bo.HESBO.registerCourse(HESBO.java:42)
    at com.cts.facade.HESFacade.registerCourse(HESFacade.java:34)
    at com.cts.manager.HESManager.registerCourse(HESManager.java:34)
    at com.cts.presentation.Tester.registerCourse(Tester.java:66)
    at com.cts.presentation.Tester.main(Tester.java:159)
**Caused by: org.postgresql.util.PsqlException: FATAL: password authentication Failed for user "admin"**
    at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:415)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:188)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
    at org.postgresql.jdbc2.AbstractJdbc2Connection.sql.jdbc3.AbstractJdbc3Connection.sql.jdbc3g.AbstractJdbc3gConnection.sql.jdbc3g.Jdbc3gConnection.sql.Driver.makeConnection(Driver.java:412)
    at org.postgresql.Driver.connect(Driver.java:280)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:173)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:164)
    at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149)
    at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119)
    at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:202)
    ... 11 more

.properties文件

jdbc.driverClassName=org.postgresql.Driver
jdbc.url=jdbc:postgresql://localhost:5432/postgres

jdbc.password=admin
jdbc.username=admin

spring.xml

对此有任何帮助非常感谢,因为这个奇怪的错误我无法进步.

最佳答案
如果您还没有尝试过,请查看您的pg_hba.conf文件.它会被命名为

/etc/postgresql/9.6/main/pg_hba.conf (Ubuntu 16.04)
/var/lib/pgsql/9.3/data/pg_hba.conf (Fedora 20);

您可能必须使用find / -name pg_hba.conf来定位它.

文件底部,将METHOD值更改为trust以进行本地测试(有关完整信息,请参阅postgres文档).重新启动postgres以确保所有内容都已开始清理并读取新的参数:

sudo systemctl restart postgresql     # ubuntu

希望这能够治愈你的困境.它解决了我在Ubuntu / Fedora上的问题.

原文链接:https://www.f2er.com/spring/431353.html

猜你在找的Spring相关文章