Hello guys,

I have some trouble with oracle BLOB.

My code work, but it's slow.

To inject the blob in the database I use this code:


        public WOComponent uploadData() {
                try {
                        // Uploading data using large object
Connection conn = YUEOUtilities.jdbcConnectionFromEditingContext ("Akira", ec());
                        
Integer rowId = (Integer)EOUtilities.primaryKeyForObject(ec(), file.content()).objectForKey("id");
                        Statement stmt = conn.createStatement();
                        
String cmd = "UPDATE ak_data set binary_data = empty_blob() where id = "+rowId;
                        stmt.executeQuery(cmd);
                        cmd = "SELECT binary_data FROM ak_data WHERE id = 
"+rowId;
                        ResultSet rset = stmt.executeQuery(cmd);
                        rset.next();
                        BLOB blob = ((OracleResultSet)rset).getBLOB(1);
                        OutputStream out = blob.setBinaryStream(0);
                        
                        // Copy the data from the file to the blob output stream
                        byte buf[] = new byte[1024*1024*10];
                        int s, tl = 0;
                        while ((s = in.read(buf, 0, 1024*1024*10)) > 0) {
                                out.write(buf, 0, s);
                                tl += s;
                                NSLog.debug.appendln("test"+s);
                        }
                        
                        
                        // Close the input stream
                        in.close();
                        out.close();
                        
                        file.setMimeType(aMimeType);
                        file.setHasContent(new Integer(1));
                        file.setName(aFileName);
                        ec().saveChanges();
                        registerMessage("C1: Upload successfull");
                } catch(Exception e) {
                        e.printStackTrace();
                }
                return null;
        }

It works fine, but it takes about 30 seconds to upload 40mb, it should take about 4-5 seconds.

Do you have any idea how to tune that? (I tried different buffer size, I set huge buffer size (10mb) for intranet text connection)

And EO seems very slow to select blob data. I stream big data, but for little images (-50ko) I simply "Select binary_data from ak_data where id = ?" (Auto generated EO).

But it takes about 4 seconds for 10 ko!!

And my last problem is deletion, when I delete the file object, I simply check the "Cascade" in relationship manager (To delete the associated Content row), but EOF select the content row before deleting it, any idea how to avoid this select? I want EO to directly delete the data row. If this is not possible I'll simply write down some lines of sql.

Regards

kuon

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Reply via email to