1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

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
This commit is contained in:
Bruce Momjian
2001-07-21 18:52:11 +00:00
parent 12f59470a1
commit ff21a8e5c8
8 changed files with 272 additions and 177 deletions

View File

@ -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]);
}
/**