我知道这些类型的问题已经存在,但提供的解决方案对我不起作用。在我的应用程序中,不存在版本不匹配的黑白驱动程序和 PostgreSQL 服务器。我还没有找到任何其他解决方案。
我正在使用 PostgreSQL 服务器 9.4 和 postgresql-9.4-1201.jdbc4.jar。
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver"></property>
<property name="username" value="postgres"></property>
<property name="password" value="root"></property>
<property name="url" value="jdbc:postgresql://localhost:5432/myapp"></property>
</bean>
pg_hba.conf 如下:
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
postgresql.conf如下
listen_addresses = '*'
port = 5432
max_connections = 100
我还检查了 netstat o/p 。
TCP [::]:5432 [::]:0 LISTENING
TCP 127.0.0.1:5432 0.0.0.0:0 LISTENING
谢谢
最佳答案
我遇到过同样的问题。
只需在 postgresql.conf 中将端口号 5432 更改为 5433。
重新启动系统。
postgresql.conf文件在windows中的位置:C:\Program Files\PostgreSQL\9.4\data
希望对你有所帮助。
关于java - org.postgresql.util.PSQLException : Protocol error. session 设置失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31091471/