最近才接觸到一個用PostgreSQL的項目,然后在開發(fā)的過程中發(fā)現(xiàn)了這樣的一個問題。
錯誤: 操作符不存在: character = integer
反正還有很多報錯的,原因都是類型的轉(zhuǎn)換問題。在mysql中似乎對類型這個概念不是那么敏感,而在PostgreSql中Integer 、Long、Date、String 等等之間轉(zhuǎn)換都會存在操作符不存在的報錯。
所以在使用非實體進(jìn)行數(shù)據(jù)傳輸?shù)臅r候,例如Map等等就需要手動設(shè)置數(shù)據(jù)類型。
Long orgId = (maps.get("orgId") != null maps.get("orgId").toString().length() > 0) ? Long.valueOf(maps.get("orgId").toString()) : null; maps.put("orgId", orgId);
就可以利用maps進(jìn)行判斷后再進(jìn)行插入修改等操作,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"
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。如有錯誤或未考慮完全的地方,望不吝賜教。
標(biāo)簽:來賓 晉城 衡陽 烏海 蚌埠 珠海 錦州 株洲
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《PostgreSQL報錯 解決操作符不存在的問題》,本文關(guān)鍵詞 PostgreSQL,報錯,解決,操作,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。