pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedpostgresql and java data types mismatch.....
4+ messages / 3 participants
[nested] [flat]
* postgresql and java data types mismatch.....
@ 2005-08-11 13:23 Andres Ledesma <aledes@euskalnet.net>
0 siblings, 1 reply; 4+ messages in thread
From: Andres Ledesma @ 2005-08-11 13:23 UTC (permalink / raw)
To: pgsql-jdbc
Hi,
I have got and issue about data types, perhaps I'm missing some info I should
know, or there is anything wrong in the code, but I would like that if
someone knows why this happens, ust explain it to me.
According to documentation, java.sql.Types.BOOLEAN is the equivalence of SQL
BOOLEAN, but a function returning a boolean, returns something matched to
Types.BIT in java. It happens in the following code.
java code:
....... vars declarations, etc...
boolean is_client = false;
//procedure call
cs = conn.prepareCall("{ ? = call get_is_client( ? ) }");
cs.registerOutParameter(1, Types.BOOLEAN);
cs.setInt(2, client_id);
cs.execute();
is_client = cs.getBoolean(1);
.....
plpgsql function :
CREATE OR REPLACE FUNCTION get_is_client() RETURNS boolean AS '
BEGIN
RETURN is_true;
END;
' LANGUAGE plpgsql;
When run the java code, I receive the following message :
A CallableStatement Function was executed and the return was of type
(java.sql.Types=-7) however type=java.sql.Types=16 was registered.
Types = -7 correspond to Types.BIT
Types = 16 correspond to Types.BOOLEAN
That's all. Thanks in advance.
Best regards.
--
Andres Ledesma
=================
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: postgresql and java data types mismatch.....
@ 2005-08-11 13:32 Oliver Jowett <oliver@opencloud.com>
parent: Andres Ledesma <aledes@euskalnet.net>
0 siblings, 2 replies; 4+ messages in thread
From: Oliver Jowett @ 2005-08-11 13:32 UTC (permalink / raw)
To: Andres Ledesma <aledes@euskalnet.net>; +Cc: pgsql-jdbc
Andres Ledesma wrote:
> According to documentation, java.sql.Types.BOOLEAN is the equivalence of SQL
> BOOLEAN, but a function returning a boolean, returns something matched to
> Types.BIT in java. It happens in the following code.
Types.BIT and Types.BOOLEAN are, as far as I can tell from the JDBC
spec, intended to be interchangeable.
> A CallableStatement Function was executed and the return was of type
> (java.sql.Types=-7) however type=java.sql.Types=16 was registered.
>
> Types = -7 correspond to Types.BIT
> Types = 16 correspond to Types.BOOLEAN
A workaround is to just register the OUT parameter as Types.BIT, but
yes, the driver shouldn't really complain in this case.
You didn't say which driver version you were using..
-O
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: postgresql and java data types mismatch.....
@ 2005-08-11 13:49 Andres Ledesma <aledes@euskalnet.net>
parent: Oliver Jowett <oliver@opencloud.com>
1 sibling, 0 replies; 4+ messages in thread
From: Andres Ledesma @ 2005-08-11 13:49 UTC (permalink / raw)
To: pgsql-jdbc
Ok, thanks for your anwsers, it's clear to me know.
> A workaround is to just register the OUT parameter as Types.BIT, but
> yes, the driver shouldn't really complain in this case.
Yes, that's the solution I have adopted.
Kindest regards,
--
Andres Ledesma
=================
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: postgresql and java data types mismatch.....
@ 2005-08-19 05:03 Kris Jurka <books@ejurka.com>
parent: Oliver Jowett <oliver@opencloud.com>
1 sibling, 0 replies; 4+ messages in thread
From: Kris Jurka @ 2005-08-19 05:03 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: Andres Ledesma <aledes@euskalnet.net>; pgsql-jdbc
On Fri, 12 Aug 2005, Oliver Jowett wrote:
> Andres Ledesma wrote:
>
>> A CallableStatement Function was executed and the return was of type
>> (java.sql.Types=-7) however type=java.sql.Types=16 was registered.
>>
>> Types = -7 correspond to Types.BIT
>> Types = 16 correspond to Types.BOOLEAN
>
> A workaround is to just register the OUT parameter as Types.BIT, but
> yes, the driver shouldn't really complain in this case.
>
Just to follow up on this, the 8.0 and 8.1 drivers correctly handle this
and do not report an error. It is still possible to generate this error
with the new drivers by using the JDBC 2 version of the driver because it
doesn't understand the JDBC 3 type BOOLEAN and thereforce cannot map it
correctly.
Kris Jurka
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2005-08-19 05:03 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-08-11 13:23 postgresql and java data types mismatch..... Andres Ledesma <aledes@euskalnet.net>
2005-08-11 13:32 ` Oliver Jowett <oliver@opencloud.com>
2005-08-11 13:49 ` Andres Ledesma <aledes@euskalnet.net>
2005-08-19 05:03 ` Kris Jurka <books@ejurka.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox