there are differences in JDBC drivers and you should check the documentation
for drivers you're using, but something like this should work
insert into database
int rows=0;
PreparedStatement pstmt = null;
try
{
pstmt = conn.prepareStatement("insert into PROVIDERS ( "+
" party_id, "+
"image ) "+
"values( "+
"?, "+
"?)");
pstmt.setInt(1,112);
File file = new File("pilo.png");
long fileLength = file.length();
FileInputStream fis = new FileInputStream(file);
pstmt.setBinaryStream(2,fis, (int)fileLength);
rows = pstmt.executeUpdate();
fis.close();
pstmt.close();
pstmt =null;
conn.commit();
}
catch (FileNotFoundException e) {
...
}
catch (IOException e) {
...
}
catch (SQLException e) {
...
}
finally {
if (stmt != null){ stmt.close();
catch Exception e) {
... }
}
}
to retrieve from database
[added code tags]
[ September 13, 2005: Message edited by: Jeanne Boyarsky ]