PostgreSQL中出现报错如何解决
更新:HHH   时间:2023-1-7


PostgreSQL中出现报错如何解决?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

错误: 操作符不存在: character = integer

反正还有很多报错的,原因都是类型的转换问题。在mysql中似乎对类型这个概念不是那么敏感,而在PostgreSql中Integer 、Long、Date、String 等等之间转换都会存在操作符不存在的报错。

所以在使用非实体进行数据传输的时候,例如Map等等就需要手动设置数据类型。

Long orgId = (maps.get("orgId") != null && maps.get("orgId").toString().length() > 0) ? Long.valueOf(maps.get("orgId").toString()) : null;
maps.put("orgId", orgId);

就可以利用maps进行判断后再进行插入修改等操作,Date格式也同理。

补充:PostgreSQL一些简单问题以及解决办法

问题:

org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

解决办法:

Edit /var/lib/pgsql/data/postgresql.conf file

Change
#listen_addresses = 'localhost'
to
listen_addresses = '*'

问题:

org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "<host_ip>", user "fkong", database "fkong", SSL off

解决办法:

Edit /var/lib/pgsql/data/pg_hba.conf file
Add below line under "# IPv4 local connections:"
"host all   all   <host_ip>/32   password"

问题:

org.postgresql.util.PSQLException: FATAL: Ident authentication failed for user "fkong"

解决办法:

Edit /var/lib/pgsql/data/pg_hba.conf file
Change
"host all   all   <host_ip>/32   ident"
to
"host all   all   <host_ip>/32   password"

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注天达云行业资讯频道,感谢您对天达云的支持。

返回开发技术教程...