mirror of
https://github.com/postgres/postgres.git
synced 2025-07-21 16:02:15 +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:
@ -5,7 +5,6 @@ package org.postgresql.jdbc2;
|
||||
// changes are also made (if relevent) to the related JDBC 1 class in the
|
||||
// org.postgresql.jdbc1 package.
|
||||
|
||||
|
||||
import java.lang.*;
|
||||
import java.io.*;
|
||||
import java.math.*;
|
||||
@ -15,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
|
||||
@ -172,16 +172,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
||||
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]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1006,15 +998,9 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
||||
|
||||
public java.io.Reader getCharacterStream(int i) throws SQLException
|
||||
{
|
||||
// New in 7.1
|
||||
try {
|
||||
String encoding = connection.getEncoding();
|
||||
if(encoding==null)
|
||||
return new InputStreamReader(getBinaryStream(i));
|
||||
return new InputStreamReader(getBinaryStream(i),encoding);
|
||||
} catch (UnsupportedEncodingException unse) {
|
||||
throw new PSQLException("postgresql.res.encoding", unse);
|
||||
}
|
||||
Encoding encoding = connection.getEncoding();
|
||||
InputStream input = getBinaryStream(i);
|
||||
return encoding.getDecodingReader(input);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user