pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
bytea encoding
4+ messages / 3 participants
[nested] [flat]

* bytea encoding
@ 2005-05-11 20:37  Jesse Eichar <jeichar@refractions.net>
  0 siblings, 1 reply; 4+ messages in thread

From: Jesse Eichar @ 2005-05-11 20:37 UTC (permalink / raw)
  To: pgsql-jdbc

Hi 

I am doing some feasibility research and have some questions about
bytea:

1. Is the byte stream (or byte array) converted to bytea on the database
side or on client before sending?  (My client is using the
postgresql-74.213.jar).

2.  If client does the encoding what will happen if the database
receives information that is already in bytea?  Will it recognize that
the data is already in bytea?

3.  Is there a way to convert an array of bytes into an array of bytea
values? 

Thank you,

Jesse




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

* Re: bytea encoding
@ 2005-05-11 21:53  Oliver Jowett <oliver@opencloud.com>
  parent: Jesse Eichar <jeichar@refractions.net>
  0 siblings, 1 reply; 4+ messages in thread

From: Oliver Jowett @ 2005-05-11 21:53 UTC (permalink / raw)
  To: Jesse Eichar <jeichar@refractions.net>; +Cc: pgsql-jdbc

Jesse Eichar wrote:

> 1. Is the byte stream (or byte array) converted to bytea on the database
> side or on client before sending?  (My client is using the
> postgresql-74.213.jar).

You give the driver a byte[] (setBytes) or InputStream
(setBinaryStream); it does the rest. Old drivers such as build 213 will,
IIRC, convert this to a text representation internally before sending to
the backend; newer drivers will send the data directly without
conversion. But this is all transparent to the client.

-O



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

* Re: bytea encoding
@ 2005-05-12 17:31  Jesse <jeichar@refractions.net>
  parent: Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Jesse @ 2005-05-12 17:31 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc

My problem is this:

I want to send a binary file in a CDATA section of an xml file to a
server that will then turn around and put the binary file a bytea
column.  

Is there a way that I can use postgresql-74.213.jar (or more recent) to
encode the file in bytea on the client side?  If no, do you know where I
can get code to do that?

If the server puts data in the database will the database recognize that
it is bytea already?

thank you,

Jesse

On Thu, 2005-05-12 at 09:53 +1200, Oliver Jowett wrote:
> Jesse Eichar wrote:
> 
> > 1. Is the byte stream (or byte array) converted to bytea on the database
> > side or on client before sending?  (My client is using the
> > postgresql-74.213.jar).
> 
> You give the driver a byte[] (setBytes) or InputStream
> (setBinaryStream); it does the rest. Old drivers such as build 213 will,
> IIRC, convert this to a text representation internally before sending to
> the backend; newer drivers will send the data directly without
> conversion. But this is all transparent to the client.
> 
> -O




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

* Re: bytea encoding
@ 2005-05-12 21:46  Oliver Jowett <oliver@opencloud.com>
  parent: Jesse <jeichar@refractions.net>
  0 siblings, 0 replies; 4+ messages in thread

From: Oliver Jowett @ 2005-05-12 21:46 UTC (permalink / raw)
  To: Jesse <jeichar@refractions.net>; +Cc: pgsql-jdbc

Jesse wrote:

> Is there a way that I can use postgresql-74.213.jar (or more recent) to
> encode the file in bytea on the client side?  If no, do you know where I
> can get code to do that?

You do not need to "encode the file in bytea". Use setBytes() or
setBinaryStream() and the driver will do the rest.

-O



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


end of thread, other threads:[~2005-05-12 21:46 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-05-11 20:37 bytea encoding Jesse Eichar <jeichar@refractions.net>
2005-05-11 21:53 ` Oliver Jowett <oliver@opencloud.com>
2005-05-12 17:31   ` Jesse <jeichar@refractions.net>
2005-05-12 21:46     ` Oliver Jowett <oliver@opencloud.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