How to have ant's <sql> task insert special chars appropriately?

From: agostonbejo <bejoag1(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to have ant's <sql> task insert special chars appropriately?
Date: 2009-09-22 10:10:13
Message-ID: 25530663.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi!

What I'm trying to do is to insert some data from a sql file into a postgres
DB by calling the <sql> ant task. My problem is that I can't get special
characters (even if they can be represented by the standard ASCII charset,
such as ä, ö, ü, é, etc.) to be inserted correctly.

When I check the DB with a DB browser such as Squirrel or pgAdmin, after
running the <sql> task they can only see question marks where these
characters are supposed to be. So does the actual web application using the
DB. (The web app can store and read such special characters seamlessly,
though. It's also OK if I enter some of them by hand with the DB browsers
mentioned above.)

This all suggests that the problem is with the way I call the <sql> task.
I've tried several versions: inserting from a sql file with iso-8859-1
encoding, then from one with utf-8 encoding. (In pgAdmin I can see the
default encoding of the DB is utf-8.)

Something like this:

<sql
encoding="ISO-8859-1"
classpath="${db.pg.classpath}"
driver="${db.pg.driver}"
url="${db.pg.connection}/${db.database.name}"
userid="${db.schema.owner.name}"
password="${db.schema.owner.pwd}"
src="${sql.pg.dir}/update/testdata.sql"
/>

(This works perfectly as long as there are no special characters.)

I tried changing the "encoding" attribute above to UTF-8, adding "SET
client_encoding = 'UTF8';" to the UTF-8 file, then to the iso-8859-1 file;
"SET client_encoding = 'LATIN1';" to the iso-8859-1 file (this latter in
addition produced the error "The server's client_encoding parameter was
changed to LATIN1. The JDBC driver requires client_encoding to be UNICODE
for correct operation.")

Does anyone have any idea how to get those special characters loaded into
the DB from a pre-written sql file (possibly with the ant <sql> task)?

Thanks,
Agoston
--
View this message in context: http://www.nabble.com/How-to-have-ant%27s-%3Csql%3E-task-insert-special-chars-appropriately--tp25530663p25530663.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tore Halvorsen 2009-09-22 10:11:46 citext like query and index usage
Previous Message Chris 2009-09-22 07:27:11 Re: Insert unique fails, still increments ID in a lookup table