Skip site navigation (1) Skip section navigation (2)

cannot dollar-quote $$?$$ in PreparedStatements

From: Marc Herbert <Marc(dot)Herbert(at)continuent(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: cannot dollar-quote $$?$$ in PreparedStatements
Date: 2006-01-11 11:41:50
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
With 8.0 postgresql and driver, this works fine:
ps = con.prepareStatement("insert into product values(?, '?' , ?)");

But this fails:
ps = con.prepareStatement("insert into product values(?, $$?$$ , ?)");

It looks like "someone" (driver or engine?) is counting 3 parameters instead of 3:

org.postgresql.util.PSQLException: Pas de valeur specifiee pour le parametre 3.
	at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(
	at org.postgresql.core.v3.QueryExecutorImpl.execute(
	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(
	at TestFetchSize.main(

How dollar-quoting and question marks are supposed to interact?
Sorry if this a well-known issue.


pgsql-jdbc by date

Next:From: Kovács PéterDate: 2006-01-11 13:54:57
Subject: Memory leak or client side caching?
Previous:From: Kris JurkaDate: 2006-01-10 21:16:51
Subject: Re: JDBC, PrepareStatement and TimeStamp problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group