Re: Implementing setBinaryStream(int, InputStream, long) - Mailing list pgsql-jdbc

From Johann 'Myrkraverk' Oskarsson
Subject Re: Implementing setBinaryStream(int, InputStream, long)
Date
Msg-id sfkxlr.x5sfkxlr.7gvp.u4om.gnus@asuka.myrkraverk.com
Whole thread Raw
In response to Re: Implementing setBinaryStream(int, InputStream, long)  ("Johann 'Myrkraverk' Oskarsson" <johann@2ndquadrant.com>)
Responses Re: Implementing setBinaryStream(int, InputStream, long)
List pgsql-jdbc
"Johann 'Myrkraverk' Oskarsson" <johann@2ndquadrant.com> writes:

> This is how the function looks with the attached patch (edited to fit
> in 80 columns).
>
>     public void setBinaryStream(int parameterIndex,
>            InputStream value, long length) throws SQLException
>     {
>     if (length > Integer.MAX_VALUE)
>         throw new PSQLException(GT.tr
>                   ("Object is too large to send over the protocol."),
>                   PSQLState.NUMERIC_CONSTANT_OUT_OF_RANGE);
>
>         preparedParameters.setBytea(parameterIndex, value, (int)length);
>     }
>
> I am not sure if the message is clear enough, nor whether the SQL state
> constant is appropriate.  Comments?

Is there any chance this can be reviewed/commented on soon?  It is the
natural way (IMO) to upload files to the server.

  File somefile = new File( "filename" );
  preparedStatement.setBinaryStream( 1,
                                     new FileInputStream( somefile ),
                                     somefile.length() );

Since File.length() is a long value. And this is how I'm using it in a
tool of mine.


--
   Johann Oskarsson                http://www.2ndquadrant.com/    |[]
   PostgreSQL Development, 24x7 Support, Training and Services  --+--
                                                                  |
   Blog: http://my.opera.com/myrkraverk/blog/

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Simple connection failover support
Next
From: Dave Cramer
Date:
Subject: Re: Implementing setBinaryStream(int, InputStream, long)