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

From Barry Lind
Subject Re: JDBC - Handle unknown encoding properly in AbstractJdbc2ResultSet
Date
Msg-id 3D7ED85E.6050304@xythos.com
Whole thread Raw
In response to JDBC - Handle unknown encoding properly in AbstractJdbc2ResultSet  (Kris Jurka <jurka@ejurka.com>)
List pgsql-patches
Patch applied.

--Barry

Kris Jurka wrote:
>
> 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;
>
>
> ------------------------------------------------------------------------
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)


pgsql-patches by date:

Previous
From: Barry Lind
Date:
Subject: Re: JDBC Driver - Batch Prepared Statements
Next
From: Barry Lind
Date:
Subject: Re: JDBC Driver - Connection.getTransactionIsolationLevel