From: Michael Guyver <kenevel@googlemail.com>
To: pgsql-jdbc <pgsql-jdbc@postgresql.org>
Subject: Trouble with CallableStatement
Date: Sun, 23 Jul 2006 01:55:42 +0100
Message-ID: <30b57570607221755q76771c94l84013aef90b16f96@mail.gmail.com> (raw)
Hi there,
I'm having trouble getting a CallableStatement to work with the
following function
CREATE OR REPLACE FUNCTION pro_register_cookie_for_user(
prmUserId int8,
prmSecureGuid varchar,
OUT outUsernameHash varchar,
OUT outMaxAge float4)
AS $$
...
$$ LANGUAGE plpgsql;
The function works fine over pgAdmin, so I think the problem lies in
the Java code.
callable = conn.prepareCall("{call pro_register_cookie_for_user(?, ?, ?, ?)}");
callable.setLong(1, playerId);
callable.setString(2, secureGuid);
callable.registerOutParameter(3, Types.VARCHAR);
callable.registerOutParameter(4, Types.FLOAT);
callable.executeQuery();
String usernameHash = callable.getString(3);
float maxAgeF = callable.getFloat(4);
When running this on Java 1.5, pgsql-jdbc 8.1.404 and Postgres 8.1, I
get the following error:
A CallableStatement function was executed and the return was of type
java.sql.Types=12 however type java.sql.Types=0 was registered.
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:380)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:250)
Can anyone shed some light on what I'm doing wrong?
Cheers
Michael
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: kenevel@googlemail.com
Subject: Re: Trouble with CallableStatement
In-Reply-To: <30b57570607221755q76771c94l84013aef90b16f96@mail.gmail.com>
References: <30b57570607221755q76771c94l84013aef90b16f96@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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