From: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: CallableStatement.getParameterMetaData() throws exception for valid {call ...} statement |
Date: | 2015-06-01 22:17:29 |
Message-ID: | mkillq$bni$1@ger.gmane.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
dmp wrote on 30.05.2015 21:50:
> Seems to work fine, maybe I have it wrong?
>
interesting, your code indeed works.
After playing around with it, the difference is that I call getParameterMetaData() *before* calling registerOutParameter().
This works:
cstmt = connection.prepareCall("{call sum_n_product(?,?,?,?)}");
cstmt.registerOutParameter(3, Types.INTEGER);
cstmt.registerOutParameter(4, Types.INTEGER);
cstmt.setInt(1, 2);
cstmt.setInt(2, 5);
cstmt.execute();
meta = cstmt.getParameterMetaData();
This also works:
cstmt = connection.prepareCall("{call sum_n_product(?,?,?,?)}");
cstmt.registerOutParameter(3, Types.INTEGER);
cstmt.registerOutParameter(4, Types.INTEGER);
meta = cstmt.getParameterMetaData();
cstmt.setInt(1, 2);
cstmt.setInt(2, 5);
cstmt.execute();
This does NOT work:
cstmt = connection.prepareCall("{call sum_n_product(?,?,?,?)}");
meta = cstmt.getParameterMetaData(); -- right after preparing the statement!
cstmt.registerOutParameter(3, Types.INTEGER);
cstmt.registerOutParameter(4, Types.INTEGER);
cstmt.setInt(1, 2);
cstmt.setInt(2, 5);
cstmt.execute();
So getParameterMetaData() seems to only work after all OUT parameters have been registered (I also tried calling it after the first registerOutParameter() - failed as well).
So how can I retrieve the information about the parameters if I can't call getParameterMetaData() before registering the parameters (which I try to detect by calling that method). The JDBC JavaDocs do not mention such a restriction.
Thomas
From | Date | Subject | |
---|---|---|---|
Next Message | dmp | 2015-06-02 16:40:11 | Re: Re: CallableStatement.getParameterMetaData() throws exception for valid {call ...} statement |
Previous Message | Alexis Meneses | 2015-06-01 21:18:44 | Re: BUG on postgresql-9.4-1201-jdbc41 ... |