Re: Implementing setBinaryStream(int, InputStream, long)
От | Dave Cramer |
---|---|
Тема | Re: Implementing setBinaryStream(int, InputStream, long) |
Дата | |
Msg-id | CADK3HHJ9g9wtw6DUvFksJvXccOk7uTz6VOxePOdu_MzV0pLdFQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Implementing setBinaryStream(int, InputStream, long) ("Johann 'Myrkraverk' Oskarsson" <johann@2ndquadrant.com>) |
Ответы |
Re: Implementing setBinaryStream(int, InputStream, long)
Re: Implementing setBinaryStream(int, InputStream, long) |
Список | pgsql-jdbc |
Johann, 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) log do something my preference is if (test) { do something } Also it would be nice if a test case came with this patch. Dave Cramer dave.cramer(at)credativ(dot)ca http://www.credativ.ca On Sat, Jun 2, 2012 at 11:14 AM, Johann 'Myrkraverk' Oskarsson <johann@2ndquadrant.com> wrote: > "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/ > > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc
В списке pgsql-jdbc по дате отправления: