Thread: Problem with copyIn(String sql, Reader from)
Hi, I tried to use copyIn(final String sql, Reader from) but I always got weird errors: ERROR: invalid byte sequence for encoding "UTF8": 0x00 I think there's a problem in CopyManager.java, the line: byte[] buf = encoding.encode(new String(cbuf)); should be byte[] buf = encoding.encode(new String(len)); ??? Otherwise the string to be encoded has always bufferSize length... filled with 0x0... Am I right? Everything works fine with the InputStream version.
Sorry, I meant byte[] buf = encoding.encode(new String(cbuf, 0, len)); ----- Messaggio originale ----- > Da: Leonardo F <m_lists@yahoo.it> > A: pgsql-jdbc@postgresql.org > Inviato: Gio 8 aprile 2010, 15:03:35 > Oggetto: [JDBC] Problem with copyIn(String sql, Reader from) > > Hi, I tried to use copyIn(final String sql, Reader from) but I always > got weird errors: ERROR: invalid byte sequence for encoding "UTF8": > 0x00 I think there's a problem in CopyManager.java, the > line: byte[] buf = encoding.encode(new > String(cbuf)); should be byte[] buf = encoding.encode(new > String(len)); ??? Otherwise the string to be encoded has > always bufferSize length... filled with 0x0... Am I > right? Everything works fine with the InputStream > version.
I think you're (sort of) right. With the current approach, I think we risk writing garbage to the COPY when we reach the end of the Reader. Your proposed solution should work. --- Maciek Sakrejda | Software Engineer | Truviso 1065 E. Hillsdale Blvd., Suite 230 Foster City, CA 94404 (650) 242-3500 Main (650) 242-3501 F www.truviso.com
On Thu, 8 Apr 2010, Leonardo F wrote: > Sorry, I meant > > byte[] buf = encoding.encode(new String(cbuf, 0, len)); > That's right. Fixed in CVS. Kris Jurka