pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Problem with copyIn(String sql, Reader from)
4+ messages / 3 participants
[nested] [flat]

* Problem with copyIn(String sql, Reader from)
@ 2010-04-08 13:03  Leonardo F <m_lists@yahoo.it>
  0 siblings, 1 reply; 4+ messages in thread

From: Leonardo F @ 2010-04-08 13:03 UTC (permalink / raw)
  To: pgsql-jdbc

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.


      



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Problem with copyIn(String sql, Reader from)
@ 2010-04-08 13:34  Leonardo F <m_lists@yahoo.it>
  parent: Leonardo F <m_lists@yahoo.it>
  0 siblings, 2 replies; 4+ messages in thread

From: Leonardo F @ 2010-04-08 13:34 UTC (permalink / raw)
  To: pgsql-jdbc

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.


      



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Problem with copyIn(String sql, Reader from)
@ 2010-04-08 15:14  Maciek Sakrejda <msakrejda@truviso.com>
  parent: Leonardo F <m_lists@yahoo.it>
  1 sibling, 0 replies; 4+ messages in thread

From: Maciek Sakrejda @ 2010-04-08 15:14 UTC (permalink / raw)
  To: Leonardo F <m_lists@yahoo.it>; +Cc: pgsql-jdbc

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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Problem with copyIn(String sql, Reader from)
@ 2010-04-08 16:18  Kris Jurka <books@ejurka.com>
  parent: Leonardo F <m_lists@yahoo.it>
  1 sibling, 0 replies; 4+ messages in thread

From: Kris Jurka @ 2010-04-08 16:18 UTC (permalink / raw)
  To: Leonardo F <m_lists@yahoo.it>; +Cc: pgsql-jdbc



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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2010-04-08 16:18 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-04-08 13:03 Problem with copyIn(String sql, Reader from) Leonardo F <m_lists@yahoo.it>
2010-04-08 13:34 ` Leonardo F <m_lists@yahoo.it>
2010-04-08 15:14   ` Maciek Sakrejda <msakrejda@truviso.com>
2010-04-08 16:18   ` Kris Jurka <books@ejurka.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox