Skip site navigation (1) Skip section navigation (2)

Re: JDBC - Handle unknown encoding properly in AbstractJdbc2ResultSet

From: Barry Lind <barry(at)xythos(dot)com>
To: Kris Jurka <jurka(at)ejurka(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: JDBC - Handle unknown encoding properly in AbstractJdbc2ResultSet
Date: 2002-09-11 05:45:02
Message-ID: 3D7ED85E.6050304@xythos.com (view raw or flat)
Thread:
Lists: 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(at)postgresql(dot)org)


In response to

pgsql-patches by date

Next:From: Barry LindDate: 2002-09-11 05:45:21
Subject: Re: JDBC Driver - Connection.getTransactionIsolationLevel
Previous:From: Barry LindDate: 2002-09-11 05:44:39
Subject: Re: JDBC Driver - Batch Prepared Statements

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group