Skip site navigation (1) Skip section navigation (2)

Re: Implementing setBinaryStream(int, InputStream, long)

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: "Johann 'Myrkraverk' Oskarsson" <johann(at)2ndquadrant(dot)com>
Cc: PostgreSQL JDBC <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Implementing setBinaryStream(int, InputStream, long)
Date: 2012-06-03 11:49:50
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

I've committed the patch with a small formatting difference.

if (test)
   do something

In my experience ends up creating hard to find bugs when someone does

if (test)
  do something

my preference is

if (test)
  do something

Also it would be nice if a test case came with this patch.
Dave Cramer


On Sat, Jun 2, 2012 at 11:14 AM, Johann 'Myrkraverk' Oskarsson
<johann(at)2ndquadrant(dot)com> wrote:
> "Johann 'Myrkraverk' Oskarsson" <johann(at)2ndquadrant(dot)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(
>>                   ("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          |[]
>   PostgreSQL Development, 24x7 Support, Training and Services  --+--
>                                                                  |
>   Blog:
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
> To make changes to your subscription:

In response to


pgsql-jdbc by date

Next:From: Mikko TiihonenDate: 2012-06-03 17:10:05
Subject: Re: Simple connection failover support
Previous:From: Johann 'Myrkraverk' OskarssonDate: 2012-06-02 15:14:17
Subject: Re: Implementing setBinaryStream(int, InputStream, long)

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group