java.io.IOException : Illegal UTF-8 sequence: initial byte is 11111xxx: 252 - Eclipse and PostgreSQL 异常

标签 java eclipse postgresql utf-8

我遵循了以下教程:

http://examples.javacodegeeks.com/core-java/java-postgresql-example/

org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:257)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:159)
at org.postgresql.Driver.makeConnection(Driver.java:415)
at org.postgresql.Driver.connect(Driver.java:283)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.javacodegeeks.examples.TestConnection.main(TestConnection.java:16)
Caused by: java.io.IOException: Illegal UTF-8 sequence: initial byte is 11111xxx: 252
at org.postgresql.core.UTF8Encoding.decode(UTF8Encoding.java:125)
at org.postgresql.core.PGStream.ReceiveString(PGStream.java:329)
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:424)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:203)
... 7 more

我正在使用 Eclipse 并在我的项目中添加了最新的 PostgreSQL JDBC 驱动程序(重命名为 postgres.jar),我的代码如教程所示。

我相信 PostgreSQL 服务器正在运行,我正在使用 Windows 10 并运行“pg_ctl start -D”,路径是正确的,据我所知服务器似乎正在工作

我已经在 pgAdmin 中检查过,数据库编码是 UTF8。

有人可以帮忙吗?

最佳答案

我遇到了同样的问题。通过为我尝试连接的用户设置密码解决了这个问题。旧版本的 JDBC 驱动程序提供了有用的错误消息。

关于java.io.IOException : Illegal UTF-8 sequence: initial byte is 11111xxx: 252 - Eclipse and PostgreSQL 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34729845/

相关文章:

Android shouldOverrideUrlLoading 在 KitKat 4.4.3 中不会被调用

java - Eclipse 在导入中未检测到 Google Analytics V4

sql - PostgreSQL 检查匹配正则表达式的表数

java - 使用 JPA/Hibernate 过滤 DataSet 中的行

java - 如何将以毫秒为单位的 java.time.LocalTime 映射为以毫秒为单位的 java.sql.Time

java - 启用gretty插件的预览功能

java - 检测双击 TableView JavaFX 的单元格

c - 将程序直接重定向到 eclipse 控制台

postgresql - 如何缩小 Heroku 上的数据库?

linux - Postgres : Pipeline to psql