Re: JDBC, PrepareStatement and TimeStamp problem

From: Kris Jurka <books(at)ejurka(dot)com>
To: Jeffrey Leegon <nogeel(at)acm(dot)org>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC, PrepareStatement and TimeStamp problem
Date: 2006-01-10 21:16:51
Message-ID: Pine.BSO.4.61.0601101614450.26551@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Marc Herbert 2006-01-11 11:41:50 cannot dollar-quote $$?$$ in PreparedStatements
Previous Message Jeffrey Leegon 2006-01-10 20:17:04 JDBC, PrepareStatement and TimeStamp problem