JDBC - Handle unknown encoding properly in AbstractJdbc2ResultSet - Mailing list pgsql-patches

From Kris Jurka
Subject JDBC - Handle unknown encoding properly in AbstractJdbc2ResultSet
Date
Msg-id 3D7D19F2.6050808@ejurka.com
Whole thread Raw
List pgsql-patches
For the UNKNOWN encoding the JDBC driver has a default encoding name
that is null.  Calling ((String)s).getBytes(null) is an error and the
apparent API is ((Encoding)e).encode((String)s) which handles the null case.

Kris Jurka
Index: src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v
retrieving revision 1.7
diff -c -r1.7 AbstractJdbc2ResultSet.java
*** src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java    2002/09/06 21:23:06    1.7
--- src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java    2002/09/09 21:55:57
***************
*** 1546,1559 ****
                  case Types.REAL:
                  case Types.TINYINT:

!                     try
!                     {
!                         rowBuffer[columnIndex] = String.valueOf( updateValues.get( columnName )
).getBytes(connection.getEncoding().name()); 
!                     }
!                     catch ( UnsupportedEncodingException ex)
!                     {
!                         throw new SQLException("Unsupported Encoding " + connection.getEncoding().name());
!                     }

                  case Types.NULL:
                      continue;
--- 1546,1552 ----
                  case Types.REAL:
                  case Types.TINYINT:

!                     rowBuffer[columnIndex] = connection.getEncoding().encode(String.valueOf( updateValues.get(
columnName) )); 

                  case Types.NULL:
                      continue;

pgsql-patches by date:

Previous
From: Kris Jurka
Date:
Subject: JDBC Driver - Connection.getTransactionIsolationLevel
Next
From: Bruno Wolff III
Date:
Subject: Updated earthdistance/cube patches