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:
@ -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]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user