Receiving "ERROR: prepared statement \"S_2\" does not exist"

See original GitHub issue

In my application I am receiving many errors regarding prepared statements not existing.

The libraries that I am using are:

  • org.postgresql/postgresql “9.4.1208”
  • hikari-cp “1.7.1” (Clojure wrapper for com.zaxxer. HikariCP)
  • And org.clojure/java.jdbc “0.6.1”

Posgres is version 9.3.11.

The operations I am performing are not very complicated. Essentially:

(with-db-connection [conn datasource]
    (let [result (j/query conn ["SELECT thing from table where column =  ?" value])]
      ;; do stuff with result
))

with-db-connection is a clojure jdbc macro that will call close on the connection at the completion of the block. The connection comes from the hikari-cp datasource so that will return the connection to the connection pool.

The actual stacktrace: “class org.postgresql.util.PSQLException: ERROR: prepared statement "S_2" does not exist” “org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284)”, “org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003)”, “org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)”, “org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)”, “org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)”, “org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:114)”, “com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)”, “com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)”, “clojure.java.jdbc$db_query_with_resultset$run_query_with_params__10416.invoke(jdbc.clj:831)”, “clojure.java.jdbc$db_query_with_resultset.invoke(jdbc.clj:847)”, “clojure.java.jdbc$query.invoke(jdbc.clj:874)”, “clojure.java.jdbc$query.invoke(jdbc.clj:867)”,

I’ve spent some time googling this stacktrace without much luck. I was hoping that someone here might have an idea of what is going on.

Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:21 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
davecramercommented, Jan 31, 2021

Named prepared statements are created after you use a statement 5 times on the same connection and save time and round trips. Setting preparedStatement=0 is the correct solution. you just won’t get the advantage of named statements

0reactions
vlsicommented, Mar 9, 2021

It would be great if protocol supported “mode sense” though. For instance, there might be a message like “please do not use named statements”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prepared statement call fails (syntax error and function does ...
Prepared statement call fails (syntax error and function does not exist) on pl/pgsql block ... Then, execution fails with error: ERROR: syntax error...
Read more >
Prepared statement does not exist - PostgreSQL
Hi,. I am not sure if sending this to the right place. I did try to get the answer from pgpool mailing list...
Read more >
Thread: Prepared statement does not exist
Looks like your app is dissconnecting from pgpool which is causing pgpool to send the RESET ALL, this will deallocate the prepared statement....
Read more >
prepared statement already exists - Google Groups
This is a cross-post to both pgbouncer and jooq lists, as I am unsure where in my stack I need to address this...
Read more >
ERROR: prepared statement "S_2" already exists"
Extract refreshes for Postgres data sources may fail with the following error: "Connectionless Failure ( status code = 10000, ERROR: prepared ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found