Subject: org.postgresql.util.PSQLException: ERROR: syntax error at or near "(" when calling org.postgresql.jdbc.PgPreparedStatement.getParameterMetaData

From: Siddharth Jain <[email-masked]>
Date: Fri, 10 Feb 2023 13:26:05 -0800

Hello,

We are using Postgres 14.4 server and 42.5.2 of org.postgresql:postgresql
to connect to it from Java.
We get following exception:
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or
near "("
  Position: 13
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:316)
at
org.postgresql.jdbc.PgPreparedStatement.getParameterMetaData(PgPreparedStatement.java:1705)
at
org.apache.commons.dbcp2.DelegatingPreparedStatement.getParameterMetaData(DelegatingPreparedStatement.java:162)
at
org.apache.commons.dbcp2.DelegatingPreparedStatement.getParameterMetaData(DelegatingPreparedStatement.java:162)
at cdao.dpde.InsertHelper.setParameters(InsertHelper.java:53)
where the code in the last line is:
ParameterMetaData parameterMetaData = query.getParameterMetaData();

How can we fix this?

S.

---

From: Prasanth <[email-masked]>
Date: Fri, 10 Feb 2023 15:33:03 -0600

Did you check the query being used? Most likely that is where the issue would be.

On 2/10/23 3:26 PM, Siddharth Jain wrote:
> Hello,
>
> We are using Postgres 14.4 server and 42.5.2 of org.postgresql:postgresql to connect to it from Java.
> Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "("
>   Position: 13
> at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676)
> at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366)
> at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356)
> at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:316)
> at org.postgresql.jdbc.PgPreparedStatement.getParameterMetaData(PgPreparedStatement.java:1705)
> at org.apache.commons.dbcp2.DelegatingPreparedStatement.getParameterMetaData(DelegatingPreparedStatement.java:162)
> at org.apache.commons.dbcp2.DelegatingPreparedStatement.getParameterMetaData(DelegatingPreparedStatement.java:162)

---

From: "David G. Johnston" <[email-masked]>
Date: Fri, 10 Feb 2023 14:34:52 -0700

> ParameterMetaData parameterMetaData = query.getParameterMetaData();
If the broken query is one generated by the driver you probably cannot, you
would need to file a bug report.  I strongly doubt your lack of
current-ness on the PostgreSQL is going to be an influence here but maybe...

In any case you are going to need something much more descriptive, and
ideally executable than this, if you actually want to debug and then file a
bug report (or fix your code if that is where the problem originates).

David J.

---

From: Siddharth Jain <[email-masked]>
Date: Fri, 10 Feb 2023 13:56:49 -0800

Thanks. query was the problem indeed. My mistake.