Selecting on non ASCII varchars - Mailing list pgsql-jdbc

From Jeremy LaCivita
Subject Selecting on non ASCII varchars
Date
Msg-id 19B7E72C-CA44-42AE-803E-E87421EC30F9@broadrelay.com
Whole thread Raw
Responses Re: Selecting on non ASCII varchars
List pgsql-jdbc
Hi,

I have a unicode database.  Inserting unicode strings works fine.
Selecting data based on int columns works fine too.

However, I am unable to select based on varchar columns when the
select contains non ascii characters.

the same select will work in Aqua Data Studio, just not from java.
Am i setting up my connections or prepared statements wrong?

/* begin example code */
javax.naming.InitialContext ctx = new javax.naming.InitialContext();
javax.sql.DataSource ref1 = (javax.sql.DataSource)ctx.lookup("java:/
PostgresDS");
Connection conn = ref1.getConnection();
PreparedStatement pst = conn.prepareStatement("SELECT * from mytable
m where m.title ~* ?");
pst.setString(1, myString);
ResultSet rs = pst.executeQuery();
/* end example code */

mytable.title is a varchar(300)
myString is a java.lang.String which was loaded from a unicode xml
stream.

whenever myString contains accented or chinese characters, for
example, the result set will be empty even though there are records
in the database that should match.  doing the same query manually in
aqua data studio works fine.

I'm using postgres 8.0.3

Any ideas?

-Jeremy

pgsql-jdbc by date:

Previous
From: Russell Francis
Date:
Subject: Re: queries against CIDR fail against 8.0.3?
Next
From: Oliver Jowett
Date:
Subject: Re: Selecting on non ASCII varchars