Writing binary - UPDATE

Поиск
Список
Период
Сортировка
Искать

Writing binary - UPDATE

От:
buki@gmx.net (Andreas Buer)
Дата:
Hi,

now I've figured out that it had something to do with the
driver version. But now I get the following message from 
ps.toString(), which shows me the right input statement,
but it won't insert anything:

INSERT INTO blob_test VALUES ('noname.bmp', 'BM\\302p\\000\\000\\000\\
.......
\\335\\316\\335\\316\\000\\000')

The table looks like this:
CREATE TABLE blobl_tbl (
  name varchar(35), 
  bmp oid
);

Thanks in advance

Andi

openDB();
// All LargeObject API calls must be within a transaction
db.setAutoCommit(false);
 
File file = new File("c:/test/noname.bmp");
FileInputStream fis = new FileInputStream(file);
PreparedStatement ps = 
           db.prepareStatement("INSERT INTO blob_test VALUES (?, ?)"); 
ps.setString(1, file.getName());
ps.setBinaryStream(2, fis, (int)file.length());
ps.executeUpdate();
FileOutputStream foust = new FileOutputStream("c:/test/b.txt");
OutputStreamWriter osw = new OutputStreamWriter(foust);	
osw.write(ps.toString());					
ps.close();
fis.close();
FAQ