Thread: Fail to write BLOB - no exception thrown

Fail to write BLOB - no exception thrown

From
"Craig Jarman"
Date:
Hi
 
I am unable to write an image file into postgres using the jdbc7.1-1.2.jar driver.
Application server runs on NT, Postgres 7.1.3 on Linux 7.1.
No exception or error is generated and the transcation appears to go through.
Yet no record is recieved into postgres.
 
Code:
 
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection("jdbc:postgresql://192.168.0.50:5432/mydb","administrator","password");
File file = new File("d:/Temp/testimage.gif");
FileInputStream fis = new FileInputStream(file);
 
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement("INSERT INTO IMAGES VALUES (?, ?)");
ps.setString(1, file.getName());
            
Long  length = new Long(file.length());
ps.setBinaryStream(2, fis,length.intValue());
ps.executeUpdate();
ps.close();
fis.close();
 
This code works for other dbs. 
______________________________
 
Craig Jarman
Source IT
Ph: 612 9974 1480
Fx: 612 9974 1280
cjarman@source.com.au
______________________________