Subject | Re: Insert pdf into firebird database using java |
---|---|
Author | jbampton@gmail.com |
Post date | 2010-04-07T10:42:38Z |
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?
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
>