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

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: (view raw, whole thread or download thread mbox)
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

pgsql-jdbc by date

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

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