PDA

View Full Version : insert bfile image in the table


rabbit
10-27-2003, 02:19 AM
Hi all,
I have new problems. I would like to store the images in Oracle as
bfile. The table and directory are produced as:
stmt.execute("CREATE TABLE btable(bid int PRIMARY KEY not null, titel
varchar2(500), bild ORDSYS.ORDImage)");

stmt.execute("CREATE OR REPLACE DIRECTORY location AS '
C:\\Programme\\eclipse-SDK-2.1.1-win32\\eclipse\\workspace\\Datei_Sammlung\\Bild_ordner
'");

The grant distributed through:
stmt.execute("GRANT READ ON DIRECTORY location TO PUBLIC WITH GRANT
OPTION");

With the following java programm, i insert the date in the btable:
PreparedStatement pstmt = con.prepareStatement("INSERT INTO
bildtable_extern VALUES(?, ?, null)");
for (int ef=1; ef<=anzahl_summe; ef++){
pstmt.setInt(1, ef);
pstmt.setString(2, ftitel[ef]);
pstmt.execute();

stmt.executeUpdate("UPDATE btable SET bild =
ORDSYS.ORDImage.init('file', 'location', '" + f_name[ef] + "') where
bid = " + ef);

OracleResultSet rs_img = (OracleResultSet)stmt.executeQuery("SELECT *
FROM btable WHERE b_id = " + ef + " FOR UPDATE");

while (rs_img.next()){
OrdImage imgObj = (OrdImage)rs_img.getCustomDatum(3,
OrdImage.getFactory());
imgObj.setProperties(); //here is wrong
OraclePreparedStatement orpstmt =
(OraclePreparedStatement)con.prepareStatement("UPDATE btable SET bild
= ? WHERE bid =" + ef);
orpstmt.setCustomDatum(1,imgObj);
orpstmt.execute();
orpstmt.close();
}
}

But i get always the error message:
java.sql.SQLException: ORA-22285: non-existent directory or file for
FILEOPEN operation
ORA-06512: in "ORDSYS.ORDIMG_PKG", line 608
ORA-06512: in "ORDSYS.ORDIMAGE", line 65
ORA-06512: in line 2

What's the trouble with Oracle interMedia? I can not set the
properties for images. But I have already read the same example in
oracle interMedia java Classes User's Guide and Reference. Why do I
always get the errors? please help. (I use oracle 9i and windows
server 2003)

thank you very much and greeting from germany


rabbit


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service