pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kalyan Koka <Kalyan.Koka@microfocus.com>
To: pgsql-jdbc@postgresql.org
Subject: Stored Procedure call using JDBC is failing
Date: Mon, 22 Oct 2018 04:20:41 -0600
Message-ID: <5BCDA47902000044000098AC@prv1-mh.provo.novell.com> (raw)

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

view thread (2+ messages)  latest in thread

Message-ID: <5BCDA47902000044000098AC@prv1-mh.provo.novell.com>
Permalink:  ../5BCDA47902000044000098AC@prv1-mh.provo.novell.com/
Also on:    postgresql.org/message-id/5BCDA47902000044000098AC@prv1-mh.provo.novell.com

 · 

reply

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: Kalyan.Koka@microfocus.com
  Subject: Re: Stored Procedure call using JDBC is failing
  In-Reply-To: <5BCDA47902000044000098AC@prv1-mh.provo.novell.com>
  References: <5BCDA47902000044000098AC@prv1-mh.provo.novell.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