diff options
author | Bruce Momjian <bruce@momjian.us> | 2001-06-01 20:57:58 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2001-06-01 20:57:58 +0000 |
commit | c9445f08826b37d9acbc82adc77a578deaa8eff9 (patch) | |
tree | 1ff7208cabca1ff11ca47a6f6a61a6beaea73191 | |
parent | c6b1ef8fe7c33e98e0323396c33710ef90824361 (diff) | |
download | postgresql-c9445f08826b37d9acbc82adc77a578deaa8eff9.tar.gz postgresql-c9445f08826b37d9acbc82adc77a578deaa8eff9.zip |
The following patch for JDBC fixes an issue with jdbc running on a
non-multibyte database loosing 8bit characters. This patch will cause
the jdbc driver to ignore the encoding reported by the database when
multibyte isn't enabled and use the JVM default in that case.
Barry Lind
-rw-r--r-- | src/interfaces/jdbc/org/postgresql/Connection.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/Connection.java b/src/interfaces/jdbc/org/postgresql/Connection.java index d5d27762a60..521005e3c9a 100644 --- a/src/interfaces/jdbc/org/postgresql/Connection.java +++ b/src/interfaces/jdbc/org/postgresql/Connection.java @@ -10,7 +10,7 @@ import org.postgresql.largeobject.*; import org.postgresql.util.*; /** - * $Id: Connection.java,v 1.15 2001/05/09 21:11:26 momjian Exp $ + * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $ * * This abstract class is used by org.postgresql.Driver to open either the JDBC1 or * JDBC2 versions of the Connection class. @@ -267,7 +267,8 @@ public abstract class Connection // firstWarning = null; - java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()"); + java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " + + "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end"); String dbEncoding = null; //retrieve DB properties @@ -319,6 +320,11 @@ public abstract class Connection } else if (dbEncoding.equals("WIN")) { dbEncoding = "Cp1252"; + } else if (dbEncoding.equals("UNKNOWN")) { + //This isn't a multibyte database so we don't have an encoding to use + //We leave dbEncoding null which will cause the default encoding for the + //JVM to be used + dbEncoding = null; } else { dbEncoding = null; } |