2525
2626public class Array implements java .sql .Array
2727{
28- private org .postgresql .Connection conn =null ;
29- private org .postgresql .Field field =null ;
30- private org .postgresql .jdbc2 .ResultSet rs =null ;
31- private int idx =0 ;
28+ private org .postgresql .Connection conn =null ;
29+ private org .postgresql .Field field =null ;
30+ private org .postgresql .jdbc2 .ResultSet rs =null ;
31+ private int idx =0 ;
32+ private String rawString =null ;
3233
3334/**
3435 * Create a new Array
@@ -38,11 +39,14 @@ public class Array implements java.sql.Array
3839 * @param field the Field descriptor for the field to load into this Array
3940 * @param rs the ResultSet from which to get the data for this Array
4041 */
41- public Array (org .postgresql .Connection conn ,int idx ,Field field ,org .postgresql .jdbc2 .ResultSet rs ) {
42+ public Array (org .postgresql .Connection conn ,int idx ,Field field ,org .postgresql .jdbc2 .ResultSet rs )
43+ throws SQLException
44+ {
4245this .conn =conn ;
4346this .field =field ;
4447this .rs =rs ;
4548this .idx =idx ;
49+ this .rawString =rs .getFixedString (idx );
4650}
4751
4852public Object getArray ()throws SQLException {
@@ -66,9 +70,8 @@ public Object getArray(long index, int count, Map map) throws SQLException {
6670Object retVal =null ;
6771
6872ArrayList array =new ArrayList ();
69- String raw =rs .getFixedString (idx );
70- if (raw !=null ) {
71- char []chars =raw .toCharArray ();
73+ if (rawString !=null ) {
74+ char []chars =rawString .toCharArray ();
7275StringBuffer sbuf =new StringBuffer ();
7376boolean foundOpen =false ;
7477boolean insideString =false ;
@@ -200,8 +203,8 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
200203fields [1 ] =new Field (conn ,"VALUE" ,field .getOID ("bool" ),1 );
201204for (int i =0 ;i <booleanArray .length ;i ++ ) {
202205byte [][]tuple =new byte [2 ][0 ];
203- tuple [0 ] =Integer .toString ((int )index +i ). getBytes ( );// Index
204- tuple [1 ] =( booleanArray [i ]?"YES" :"NO" ). getBytes ( );// Value
206+ tuple [0 ] =conn . getEncoding (). encode ( Integer .toString ((int )index +i ) );// Index
207+ tuple [1 ] =conn . getEncoding (). encode ( ( booleanArray [i ]?"YES" :"NO" ) );// Value
205208rows .addElement (tuple );
206209}
207210case Types .SMALLINT :
@@ -212,8 +215,8 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
212215fields [1 ] =new Field (conn ,"VALUE" ,field .getOID ("int4" ),4 );
213216for (int i =0 ;i <intArray .length ;i ++ ) {
214217byte [][]tuple =new byte [2 ][0 ];
215- tuple [0 ] =Integer .toString ((int )index +i ). getBytes ( );// Index
216- tuple [1 ] =Integer .toString (intArray [i ]). getBytes ( );// Value
218+ tuple [0 ] =conn . getEncoding (). encode ( Integer .toString ((int )index +i ) );// Index
219+ tuple [1 ] =conn . getEncoding (). encode ( Integer .toString (intArray [i ]) );// Value
217220rows .addElement (tuple );
218221}
219222break ;
@@ -222,8 +225,8 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
222225fields [1 ] =new Field (conn ,"VALUE" ,field .getOID ("int8" ),8 );
223226for (int i =0 ;i <longArray .length ;i ++ ) {
224227byte [][]tuple =new byte [2 ][0 ];
225- tuple [0 ] =Integer .toString ((int )index +i ). getBytes ( );// Index
226- tuple [1 ] =Long .toString (longArray [i ]). getBytes ( );// Value
228+ tuple [0 ] =conn . getEncoding (). encode ( Integer .toString ((int )index +i ) );// Index
229+ tuple [1 ] =conn . getEncoding (). encode ( Long .toString (longArray [i ]) );// Value
227230rows .addElement (tuple );
228231}
229232break ;
@@ -232,8 +235,8 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
232235fields [1 ] =new Field (conn ,"VALUE" ,field .getOID ("numeric" ), -1 );
233236for (int i =0 ;i <bdArray .length ;i ++ ) {
234237byte [][]tuple =new byte [2 ][0 ];
235- tuple [0 ] =Integer .toString ((int )index +i ). getBytes ( );// Index
236- tuple [1 ] =bdArray [i ].toString (). getBytes ( );// Value
238+ tuple [0 ] =conn . getEncoding (). encode ( Integer .toString ((int )index +i ) );// Index
239+ tuple [1 ] =conn . getEncoding (). encode ( bdArray [i ].toString () );// Value
237240rows .addElement (tuple );
238241}
239242break ;
@@ -242,8 +245,8 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
242245fields [1 ] =new Field (conn ,"VALUE" ,field .getOID ("float4" ),4 );
243246for (int i =0 ;i <floatArray .length ;i ++ ) {
244247byte [][]tuple =new byte [2 ][0 ];
245- tuple [0 ] =Integer .toString ((int )index +i ). getBytes ( );// Index
246- tuple [1 ] =Float .toString (floatArray [i ]). getBytes ( );// Value
248+ tuple [0 ] =conn . getEncoding (). encode ( Integer .toString ((int )index +i ) );// Index
249+ tuple [1 ] =conn . getEncoding (). encode ( Float .toString (floatArray [i ]) );// Value
247250rows .addElement (tuple );
248251}
249252break ;
@@ -252,8 +255,8 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
252255fields [1 ] =new Field (conn ,"VALUE" ,field .getOID ("float8" ),8 );
253256for (int i =0 ;i <doubleArray .length ;i ++ ) {
254257byte [][]tuple =new byte [2 ][0 ];
255- tuple [0 ] =Integer .toString ((int )index +i ). getBytes ( );// Index
256- tuple [1 ] =Double .toString (doubleArray [i ]). getBytes ( );// Value
258+ tuple [0 ] =conn . getEncoding (). encode ( Integer .toString ((int )index +i ) );// Index
259+ tuple [1 ] =conn . getEncoding (). encode ( Double .toString (doubleArray [i ]) );// Value
257260rows .addElement (tuple );
258261}
259262break ;
@@ -265,8 +268,8 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
265268fields [1 ] =new Field (conn ,"VALUE" ,field .getOID ("varchar" ), -1 );
266269for (int i =0 ;i <strArray .length ;i ++ ) {
267270byte [][]tuple =new byte [2 ][0 ];
268- tuple [0 ] =Integer .toString ((int )index +i ). getBytes ( );// Index
269- tuple [1 ] =strArray [i ]. getBytes ( );// Value
271+ tuple [0 ] =conn . getEncoding (). encode ( Integer .toString ((int )index +i ) );// Index
272+ tuple [1 ] =conn . getEncoding (). encode ( strArray [i ] );// Value
270273rows .addElement (tuple );
271274}
272275break ;
@@ -275,8 +278,8 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
275278fields [1 ] =new Field (conn ,"VALUE" ,field .getOID ("date" ),4 );
276279for (int i =0 ;i <dateArray .length ;i ++ ) {
277280byte [][]tuple =new byte [2 ][0 ];
278- tuple [0 ] =Integer .toString ((int )index +i ). getBytes ( );// Index
279- tuple [1 ] =dateArray [i ].toString (). getBytes ( );// Value
281+ tuple [0 ] =conn . getEncoding (). encode ( Integer .toString ((int )index +i ) );// Index
282+ tuple [1 ] =conn . getEncoding (). encode ( dateArray [i ].toString () );// Value
280283rows .addElement (tuple );
281284}
282285break ;
@@ -285,8 +288,8 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
285288fields [1 ] =new Field (conn ,"VALUE" ,field .getOID ("time" ),8 );
286289for (int i =0 ;i <timeArray .length ;i ++ ) {
287290byte [][]tuple =new byte [2 ][0 ];
288- tuple [0 ] =Integer .toString ((int )index +i ). getBytes ( );// Index
289- tuple [1 ] =timeArray [i ].toString (). getBytes ( );// Value
291+ tuple [0 ] =conn . getEncoding (). encode ( Integer .toString ((int )index +i ) );// Index
292+ tuple [1 ] =conn . getEncoding (). encode ( timeArray [i ].toString () );// Value
290293rows .addElement (tuple );
291294}
292295break ;
@@ -295,8 +298,8 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
295298fields [1 ] =new Field (conn ,"VALUE" ,field .getOID ("timestamp" ),8 );
296299for (int i =0 ;i <timestampArray .length ;i ++ ) {
297300byte [][]tuple =new byte [2 ][0 ];
298- tuple [0 ] =Integer .toString ((int )index +i ). getBytes ( );// Index
299- tuple [1 ] =timestampArray [i ].toString (). getBytes ( );// Value
301+ tuple [0 ] =conn . getEncoding (). encode ( Integer .toString ((int )index +i ) );// Index
302+ tuple [1 ] =conn . getEncoding (). encode ( timestampArray [i ].toString () );// Value
300303rows .addElement (tuple );
301304}
302305break ;
@@ -308,5 +311,7 @@ public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map)
308311}
309312return new ResultSet ((org .postgresql .jdbc2 .Connection )conn ,fields ,rows ,"OK" ,1 );
310313}
314+
315+ public String toString () {return rawString ; }
311316}
312317