I have some Problems with using PostgresSQL with Java. When i have a Prepared Query and one of the parameter is boolean like "blocked" i get this error message:
ERROR column "blocked" is Type bit but Expression has type boolean
My Code for this is:
else if (param instanceof Boolean)
{
p.setBoolean(j, (boolean) param);
}
Any idears how to solve this?
A Postgres bit
is not a boolean
. You can insert a bit value using string 1
or 0
:
p.setBoolean(j, param ? "1" : "0");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.