Subject AW: [Firebird-Java] Re: Insert pdf into firebird database using java
Author Steffen Heil
use setBinaryStream.

-----Urspr√ľngliche Nachricht-----
Von: Firebird-Java@yahoogroups.com [mailto:Firebird-Java@yahoogroups.com] Im
Auftrag von jbampton@...
Gesendet: Mittwoch, 7. April 2010 12:43
An: Firebird-Java@yahoogroups.com
Betreff: [Firebird-Java] Re: Insert pdf into firebird database using java

I get an error: The method setInputStream(int, FileInputStream) is undefined
for the type PreparedStatement.

And when I look in the java docs there is no method setInputStream for
preparedstatement.

Anyone else got and ideas?


--- In Firebird-Java@yahoogroups.com, Roman Rokytskyy <roman@...> wrote:
>
> > I am wondering how to insert a pdf file into a table in a firebird
> > database? I am using Java
> >
> > Anyone got an example I can use?
>
> Assuming that you have database "test" set up and a table has two columns:
>
> CREATE TABLE TEST_PDF(
> ID INTEGER NOT NULL PRIMARY KEY,
> PDF_CONTENT BLOB
> );
>
> then your Java code would look like this:
>
> Connection c = DriverManager.openConnection(
> "jdbc:firebirdsql:localhost/3050:test",
> "SYSDBA",
> "masterkey");
>
> try {
> PreparedStatement stmt = c.prepareStatement(
> "INSERT INTO test_pdf VALUES(?, ?)");
> try {
> stmt.setInteger(1, <someId>);
> stmt.setInputStream(2,
> new FileInputStream("c:/my.pdf"));
>
> stmt.executeUpdate();
> } finally {
> stmt.close();
> }
> } finally {
> c.close();
> }
>
>
>
>
> Roman
>




------------------------------------

Yahoo! Groups Links




[Non-text portions of this message have been removed]