Subject Re: [Firebird-Java] Insert pdf into firebird database using java
Author Roman Rokytskyy
> 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