From: | Ermengol Bota <ebota(at)uoc(dot)edu> |
---|---|
To: | |
Cc: | PostgreSQL JDBC <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Problems with BIT datatype and preparedStatment |
Date: | 2012-11-26 18:43:00 |
Message-ID: | CABX=gB5B2wyW0oAmugaB2gMQz3LdmASjACjxhGfA38HMgCEq9A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
2012/11/26 dmp <danap(at)ttc-cmc(dot)net>
> Hello,
>
> A search of the forum may turn up a better answer, but:
I searched "the web" :-D and I just found the code below that it's supposed
to work. I thought that the patch sended was included "by default" in newer
jdbc versions...
http://archives.postgresql.**org/pgsql-patches/2003-06/**msg00402.php<http://archives.postgresql.org/pgsql-patches/2003-06/msg00402.php>
btw, which forum do you refer?
So the first problem with your execution above is you have tried to
> insert a PostgreSQL boolean type into a defined PostgreSQL bit type.
> You definition is actually by default bit(1), it could have been
> bit(2) has the example bit2_type above. Can not use setBoolean() with
> bit type in the way you have tried.
>
> The one way that it can be done has I have seen before would be to
> do a CAST.
>
> pstmt = con.prepareStatement("INSERT INTO jdbc_demo VALUES (?::bit)");
> pstmt.setString(1, "1");
This way works! great :-)
I'm not used to do cast conversion on the prepareStatement definition,
thank you for the clue!
Now I see that I didn't understand the hint at the error message "Hint: You
will need to rewrite or cast the expression."
Thanks a lot.
--
* Ermengol *
*************************************************
* Els ordinadors no resolen problemes, *
* simplement executen solucions *
*************************************************
From | Date | Subject | |
---|---|---|---|
Next Message | dmp | 2012-11-26 19:21:20 | Re: Problems with BIT datatype and preparedStatment |
Previous Message | dmp | 2012-11-26 17:43:59 | Re: Problems with BIT datatype and preparedStatment |