Re: COPY command works with older driver but not newer one ?

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Warren Bell <warren(at)clarksnutrition(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: COPY command works with older driver but not newer one ?
Date: 2009-01-11 21:22:24
Message-ID: 496A6310.5060306@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Warren Bell wrote:
> I have a COPY command that only works with 7.1.2 JDBC2 (jdbc7.1-1.2.jar)
> and not 8.3 JDBC3 with SSL (build 603) (postgresql-8.3-603.jdbc3.jar).
> Here is my test code and my debug and error messages are below it.
> Database version is 8.1. import is a table with several char fields,
> test.txt is a tab delimited file with the correct permissions on it and
> the connection to the db is being made with the postgres superuser. What
> do I need to do to get the newer driver to work?

You will need to synthesize the complete query string yourself instead
of using a parameter placeholder, as it appears that the server doesn't
support a parameter placeholder as the filename argument to COPY FROM.
This is similar to how you can't use parameter placeholders for table
names, etc - the driver is limited by where the server's query parser
will accept a $1, $2, etc in the query string.

Though I'm not sure why the server doesn't allow this case, it seems
like the argument to COPY FROM is data, not structural. Perhaps the FROM
STDIN case is the problem.

-O

> 19:18:01.025 (1) FE=> Parse(stmt=null,query="COPY import FROM $1",oids={1043})
> 19:18:01.029 (1) FE=> Bind(stmt=null,portal=null,$1=</Users/Warren/Desktop/test.txt>)

> 19:18:01.048 (1) <=BE ErrorMessage(ERROR: syntax error at or near "$1"

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Warren Bell 2009-01-12 02:28:13 Re: COPY command works with older driver but not newer one ?
Previous Message Warren Bell 2009-01-11 19:35:46 COPY command works with older driver but not newer one ?