diff options
author | Bruce Momjian <bruce@momjian.us> | 2001-07-21 18:52:11 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2001-07-21 18:52:11 +0000 |
commit | ff21a8e5c86457e205ff7c598b930efd711cb2dc (patch) | |
tree | 955c54da8f03c6fcc5f1fc9bbbfd086a42f2a372 /src/interfaces/jdbc/org/postgresql/jdbc1 | |
parent | 12f59470a12af234624c5321915b8d025a840eb7 (diff) |
JDBC encoding additions.
Here's a patch against the current CVS. The changes from the previous
patch are mostly related to the changed interface for PG_Stream.
Anders Bengtsson
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/jdbc1')
-rw-r--r-- | src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java index 47939a48103..0a28f7eb3ed 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java @@ -14,6 +14,7 @@ import java.sql.*; import org.postgresql.Field; import org.postgresql.largeobject.*; import org.postgresql.util.*; +import org.postgresql.core.Encoding; /** * A ResultSet provides access to a table of data generated by executing a @@ -154,26 +155,15 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu */ public String getString(int columnIndex) throws SQLException { - //byte[] bytes = getBytes(columnIndex); - // - //if (bytes == null) - //return null; - //return new String(bytes); if (columnIndex < 1 || columnIndex > fields.length) throw new PSQLException("postgresql.res.colrange"); + wasNullFlag = (this_row[columnIndex - 1] == null); if(wasNullFlag) return null; - String encoding = connection.getEncoding(); - if (encoding == null) - return new String(this_row[columnIndex - 1]); - else { - try { - return new String(this_row[columnIndex - 1], encoding); - } catch (UnsupportedEncodingException unse) { - throw new PSQLException("postgresql.res.encoding", unse); - } - } + + Encoding encoding = connection.getEncoding(); + return encoding.decode(this_row[columnIndex - 1]); } /** |