Re: JDBC, PrepareStatement and TimeStamp problem - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: JDBC, PrepareStatement and TimeStamp problem
Date
Msg-id Pine.BSO.4.61.0601101614450.26551@leary.csoft.net
Whole thread Raw
In response to JDBC, PrepareStatement and TimeStamp problem  (Jeffrey Leegon <nogeel@acm.org>)
List pgsql-jdbc

On Tue, 10 Jan 2006, Jeffrey Leegon wrote:

> String tableName = "\"AdultData\"";
> String tempSql = "SELECT [some stuff] FROM ? WHERE [some conditions]";
> query = conn.prepareStatement(tempSql);
> query.setString(1, tableName);
>
> java.sql.SQLException: ERROR: syntax error at or near "$1"
>     at

You cannot use placeholders for stuctural parts of your query, only
parameters.  The server cannot create a prepared plan if it doesn't even
know what table you are operating on.

Kris Jurka

pgsql-jdbc by date:

Previous
From: Jeffrey Leegon
Date:
Subject: JDBC, PrepareStatement and TimeStamp problem
Next
From: Marc Herbert
Date:
Subject: cannot dollar-quote $$?$$ in PreparedStatements