pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedStored Procedure call using JDBC is failing
2+ messages / 2 participants
[nested] [flat]
* Stored Procedure call using JDBC is failing
@ 2018-10-22 10:20 Kalyan Koka <Kalyan.Koka@microfocus.com>
0 siblings, 1 reply; 2+ messages in thread
From: Kalyan Koka @ 2018-10-22 10:20 UTC (permalink / raw)
To: pgsql-jdbc
Hi,
Stored procedure execution using JDBC is failing.
JDBC driver build number: 42.2.5
Server version: PostgreSQL 11
Exact error message and stacktrace:
org.postgresql.util.PSQLException: ERROR: testproc(integer, integer, character varying) is a procedure
Hint: To call a procedure, use CALL.
Position: 15
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143)
at org.postgresql.jdbc.PgCallableStatement.executeWithFlags(PgCallableStatement.java:77)
at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:132)
at StoredProcedureTest.properCase(StoredProcedureTest.java:42)
at StoredProcedureTest.main(StoredProcedureTest.java:65)
What you were doing, ideally in code form:
CREATE OR REPLACE PROCEDURE public.testproc(
batchcount bigint DEFAULT 100000,
INOUT outcount bigint DEFAULT 0,
INOUT errormsg character varying DEFAULT ' ')
..............................
Java code:
String commandText = "{ call testproc(?,?,?) }";
CallableStatement stmt = conn.prepareCall(commandText);
stmt.setInt(1, new Integer("10000"));
stmt.setInt(2, new Integer("0"));
stmt.setString(3, new String("Start"));
stmt.registerOutParameter(2, Types.INTEGER);
stmt.registerOutParameter(3, Types.VARCHAR);
stmt.execute();
Regards,
Kalyan Koka
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Stored Procedure call using JDBC is failing
@ 2018-10-22 16:07 Jorge Solórzano <jorsol@gmail.com>
parent: Kalyan Koka <Kalyan.Koka@microfocus.com>
0 siblings, 0 replies; 2+ messages in thread
From: Jorge Solórzano @ 2018-10-22 16:07 UTC (permalink / raw)
To: Kalyan.Koka@microfocus.com; +Cc: pgsql-jdbc
Execute stored procedures from JDBC is not supperted per discussion of the
CALL behavior:
https://www.postgresql.org/message-id/4285.1537201440%40sss.pgh.pa.us
People will need to realize that CALL behavior is still a work in
> progress. That may mean that JDBC etc shouldn't try to support it
> yet, which isn't great, but none of the above options would have
> led to near-term support of CALL in JDBC ...
>
On Mon, Oct 22, 2018 at 6:03 PM Kalyan Koka <Kalyan.Koka@microfocus.com>
wrote:
> Hi,
>
> Stored procedure execution using JDBC is failing.
>
> JDBC driver build number: 42.2.5
> Server version: PostgreSQL 11
>
>
> Exact error message and stacktrace:
> org.postgresql.util.PSQLException: ERROR: testproc(integer, integer,
> character varying) is a procedure
> Hint: To call a procedure, use CALL.
> Position: 15
> at
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
> at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
> at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
> at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
> at
> org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143)
> at
> org.postgresql.jdbc.PgCallableStatement.executeWithFlags(PgCallableStatement.java:77)
> at
> org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:132)
> at StoredProcedureTest.properCase(StoredProcedureTest.java:42)
> at StoredProcedureTest.main(StoredProcedureTest.java:65)
>
>
>
> What you were doing, ideally in code form:
>
>
> CREATE OR REPLACE PROCEDURE public.testproc(
> batchcount bigint DEFAULT 100000,
> INOUT outcount bigint DEFAULT 0,
> INOUT errormsg character varying DEFAULT ' ')
> ..............................
>
> Java code:
>
> String commandText = "{ call testproc(?,?,?) }";
> CallableStatement stmt = conn.prepareCall(commandText);
>
> stmt.setInt(1, new Integer("10000"));
> stmt.setInt(2, new Integer("0"));
> stmt.setString(3, new String("Start"));
> stmt.registerOutParameter(2, Types.INTEGER);
> stmt.registerOutParameter(3, Types.VARCHAR);
>
>
> stmt.execute();
>
>
>
>
> Regards,
> Kalyan Koka
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-10-22 16:07 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-22 10:20 Stored Procedure call using JDBC is failing Kalyan Koka <Kalyan.Koka@microfocus.com>
2018-10-22 16:07 ` Jorge Solórzano <jorsol@gmail.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