Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 023E49FB4E8 for ; Wed, 25 Apr 2007 09:29:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 29969-05 for ; Wed, 25 Apr 2007 09:29:33 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from beaver.fastcrypt.com (beaver.fastcrypt.com [64.7.141.17]) by postgresql.org (Postfix) with ESMTP id 764659FB510 for ; Wed, 25 Apr 2007 09:29:38 -0300 (ADT) Received: from [192.168.1.14] (dcdsl.ebox.com [64.7.143.116]) by beaver.fastcrypt.com (Postfix) with ESMTP id 6F64A1580657; Wed, 25 Apr 2007 08:34:55 -0400 (EDT) In-Reply-To: <462F3BE4.7080503@abanka.co.yu> References: <462F3BE4.7080503@abanka.co.yu> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: pgsql-jdbc@postgresql.org Content-Transfer-Encoding: 7bit From: Dave Cramer Subject: Re: Prepared statement problem Date: Wed, 25 Apr 2007 08:29:38 -0400 To: Djordje Nikolic X-Mailer: Apple Mail (2.752.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/117 X-Sequence-Number: 16966 jdbc is using server side prepared statements. As such the server won't allow this particular construct. You can put the ? in for where something = ? Dave On 25-Apr-07, at 7:30 AM, Djordje Nikolic wrote: > I had a problem with PreparedStatement which uses ? after FROM clause. > Server reported org.postgresql.util.PSQLException: ERROR: syntax > error at or near "$1" > > This is simplified example. > > PreparedStatement pstmt; > try { > pstmt = conn.prepareStatement("SELECT * FROM ?"); > pstmt.setString(1, "ps_nalog"); > pstmt.executeQuery(); > } catch (SQLException ex) { > ex.printStackTrace(); > } > > Can anybody tell me where is posibble to put ? in a SELECT statement ! > > best regards, > Djordje Nikolic > > www.abanka.co.yu > > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 2: Don't 'kill -9' the postmaster