pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedTrouble with CallableStatement
3+ messages / 1 participants
[nested] [flat]
* Trouble with CallableStatement
@ 2006-07-23 00:55 Michael Guyver <kenevel@googlemail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Michael Guyver @ 2006-07-23 00:55 UTC (permalink / raw)
To: pgsql-jdbc
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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Trouble with CallableStatement
@ 2006-07-23 11:27 Michael Guyver <kenevel@googlemail.com>
parent: Michael Guyver <kenevel@googlemail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Michael Guyver @ 2006-07-23 11:27 UTC (permalink / raw)
To: pgsql-jdbc
Hi there,
Having followed Adam's advice and prevented the original error by
upgrading the Jar to
8.1-407, I now get a different exception. For the same function:
CREATE OR REPLACE FUNCTION pro_register_cookie_for_user(
prmUserId int8,
prmSecureGuid varchar,
OUT outUsernameHash varchar,
OUT outMaxAge float4)
AS $$
...
$$ LANGUAGE plpgsql;
I now get the following error:
org.postgresql.util.PSQLException: No results were returned by the query.
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:259)
This is caused by the AbstractJdbc2Statement.executeWithFlags(int)
method returning false for any code path which satisfies the condition
(isFunction && returnTypeSet).
This appears to be at best mis-reported as I can clearly see the
results being read into the abstractJdbc2Statement.callResult
instance variable.
Is this right?
Michael
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Trouble with CallableStatement
@ 2006-07-23 12:04 Michael Guyver <kenevel@googlemail.com>
parent: Michael Guyver <kenevel@googlemail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Michael Guyver @ 2006-07-23 12:04 UTC (permalink / raw)
To: pgsql-jdbc
On 23/07/06, Michael Guyver <kenevel@googlemail.com> wrote:
> This is caused by the AbstractJdbc2Statement.executeWithFlags(int)
> method returning false for any code path which satisfies the condition
> (isFunction && returnTypeSet).
>
> This appears to be at best mis-reported as I can clearly see the
> results being read into the abstractJdbc2Statement.callResult
> instance variable.
>
> Is this right?
Gents,
My apologies, this one is my fault. In attempting to circumvent the
original problem I was experimenting with different ways of calling
the procedure, and had left my own code as running
statement.executeQuery() instead of statement.execute().
Michael
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-07-23 12:04 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-07-23 00:55 Trouble with CallableStatement Michael Guyver <kenevel@googlemail.com>
2006-07-23 11:27 ` Michael Guyver <kenevel@googlemail.com>
2006-07-23 12:04 ` Michael Guyver <kenevel@googlemail.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