X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 260969FB3A8 for ; Wed, 23 Aug 2006 01:09:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 86866-01 for ; Wed, 23 Aug 2006 04:09:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.181]) by postgresql.org (Postfix) with ESMTP id DA3109FB3A6 for ; Wed, 23 Aug 2006 01:09:06 -0300 (ADT) Received: by py-out-1112.google.com with SMTP id d80so7451pyd for ; Tue, 22 Aug 2006 21:09:04 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=SJd1M7S4dUPwgFmRO1Xi+jrvsTLsCNN9ToGoGeFMZxRL9kf6Wqpif5FxVFYZeKfQ8r4CKMbEq047RDxyLtHBfmnHfL4JD7VgKC8UHxXwsrb3dTdChQReql05emfLKGl7a71WCX0pSFlS+X9hfuQtaA13/5e4wdkS5nFqxVHVqZg= Received: by 10.35.38.17 with SMTP id q17mr16976912pyj; Tue, 22 Aug 2006 21:09:04 -0700 (PDT) Received: by 10.35.49.2 with HTTP; Tue, 22 Aug 2006 21:09:03 -0700 (PDT) Message-ID: <925094a20608222109s438a5b41g2886f41e9ddf7417@mail.gmail.com> Date: Wed, 23 Aug 2006 14:09:03 +1000 From: "Justin Waddell" To: pgsql-jdbc@postgresql.org Subject: Cannot use prepared statements with create user command MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.816 tagged_above=0 required=5 tests=SPF_HELO_SOFTFAIL, SPF_SOFTFAIL X-Spam-Level: *** X-Archive-Number: 200608/102 X-Sequence-Number: 15629 To avoid SQL injection attacks I am keen to use prepared statements for all JDBC calls. However prepared statements do not work with the CREATE USER command. I am using the following command: CREATE USER ? PASSWORD ? CREATEUSER and then setting the parameters before executing it. This causes the following exception: org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1" at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1525) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1309) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347) If a prepared statement is not used, then this command is definitely open to SQL injection attacks - I dropped a database table by using the following username: blah;drop table dummy;--