How to create and write a BLOB using ImmediateAccess

Hi there,
I'd like to write a BLOB using ScrollableRowSetAccess an ImmediateAccess and thereby want to avoid the use of any SQL-statements.
The problem is that I can't write to an empty BLOB, so that I have to create a dummy-Blob using BLOBDomain and overwrite it afterwards (see code below).
It should be possible to avoid the creation of a dummy-BLOB but I don't know how. Could you please send me a corrected version of my code?
Thanks in advance
write File with filename to the column with index col /(or the column with name colname, if specified) of the table that is specified by ResultSetInfo rsi
public static void writeFileToBlob(int col, String colname, ResultSetInfo rsi, String filename, SessionInfo _sessionInfo)
FileInputStream fin;
Object obj;
ScrollableRowsetAccess srsa= _rsi.getRowsetAccess();
ImmediateAccess ia;
byte []mybytes;
BlobDomain
BLOB blob;
OutputStream out;
byte []myBuffer;
int bytesRead=0;
try{
//open file
fin = new FileInputStream(_filename);
//lock Row
srsa.lockRow();
if (_colname==null)
ia = (ImmediateAccess)srsa.getColumnItem(_col);
else
ia = (ImmediateAccess)srsa.getColumnItem(_colname);
obj= ia.getValueAsObject();
//insert a dummy-BLOB of size 1-byte
mybytes= new byte[1];
blobDom= new BlobDomain();
blobDom.setBytes(mybytes); //ein Byte in den BLOB schreiben
ia.setValue(blobDom); //Wert in Zeile einf|gen
//commit Data
_sessionInfo.getApplicationModule().getTransaction().commit();
//access previously created dummy-Blob
srsa.lockRow();
if (_colname==null)
ia = (ImmediateAccess)srsa.getColumnItem(_col);
else
ia = (ImmediateAccess)srsa.getColumnItem(_colname);
obj= ia.getValueAsObject();
//assign the BLOB
blob= (BLOB) obj;
//open BLOB for writing
out= blob.getBinaryOutputStream();
myBuffer= new byte[10*1024];
//read file and write the BLOB
while ((bytesRead= fin.read(myBuffer)) !=-1)
out.write(myBuffer, 0, bytesRead);
out.flush();
out.close();
fin.close();
ia.setValue(blob);
//commmit data
_sessionInfo.getApplicationModule().getTransaction().commit();
}catch(Exception e){System.out.println("writeblob:"+e);}
null

Here are the issues with your usage of BlobDomain:
1. Streaming support is not implemented in 3.2 version of BlobDomain. It'll be implemented in our next release.
2. Your casting of object returned from getColumnItem is illegal as the objects will be of type BlobDomain and not BLOB.
3. When you create an empty BlobDomain you're in-effect meaning to call the empty_blob() method on the sql-row to create a empty blob locator.
4. You need to use getBytes(), setBytes() to read data out/set data into a blob/clob domain object in JDev 3.2
5. Casting/using oracle.sql.BLOB may lead to non-portable code (you're binding to the jdbc objects which may not be available in all tiers of deployment).
Here's the pseudocode you could use for new blobs.
1. create a new instance of BlobDomain()
2. setBytes() with actual data read from a stream. (Yes this may not work with real large blobs but we've tested blobs ~2MB in size and for larger needs, we're implementing the streaming support scheduled for our next release).
3. set the domain object into an attribute.
4. post/commit your data.
null

Similar Messages

  • How to Create and Deploy Web Services Using Oracle 9i JDeveloper

    Hi,
    My Question is how to create and deploy Web Services using Oracle 9i JDeveloper.Anybody please give me a detailed Reply.Please Reply to [email protected]
    Hopr to Hear From you,
    Regards,
    G Sreekumar

    You could use datasources. You should do this in your BC4J Configuration. Then when deploying your applicaiton use the command -installDataSource (from admin.jar) to create the right datasource.
    You could probably use the name of your connection + "DS" so you can also use it locally in JDeveloper as JDev seesm to create this automaticly for your Connections.

  • How to create and read text file using LabVIEW 7.1 PDA module?

    How to create and read text file using LabVIEW 7.1 PDA module? I can not create a text file and read it.
    I attach my code here.
    Attachments:
    File_IO.vi ‏82 KB

    Well my acquisition code runs perfect. The problem is reading it. I can't seem to read my data no matter what I do. My data gets saved as a string using the array to string vi but I've read that the string to array vi (which I need to convert back to array to read my data) does not work on the pda. I'm using version 8.0. So I was trying to modify the program posted in this discussion so that it would save data from my DAQ. I did that but I still can't read the data after its saved. I really don't know what else to do. All I need to do is read the data on the pda itself. I can't understand why I'm having such a hard time doing that. I found a possible solution on another discussion that talks about parsing the strings because of the bug in the "string to array" vi. However, that lead me to another problem because for some reason, the array indicators or graphs don't function on the pda. When i build the program to the pda or emulator, the array indicators are faded out on the front panel as if the function is not valid. Does this kind of help give a better picture of what I'm trying to do. Simply read data back. Thanks.

  • How to create and print contact sheet using photoshop elements 10?

    how to create and print contact sheet with photoshop 10?

    Which operating system are you using?
    On a windows system you can use the Organizer
    http://www.dummies.com/how-to/content/how-to-print-contact-sheets-in-photoshop-elements-.h tml
    On a Mac, File>Contact Sheet II within the pse 10 editor

  • How to create  and hide a drive using java?

    I want to ask how to create a temporary drive/ or a drive by allocating some space of existing drives(eg allocating some space of C: Drive such as 5mb for storing files on the new drive that has been created) and then i want to hide that drive .So Please can anyone Explain me how to do that.

    Iam saying to all of you iam not blaming to anyone even java. And my harddisk is not currepted or damage by using that. My harddisk is working properly. But i don't know why all of you think that i am blamming to someone but iam asking some question which need to be answered.
    I am clearing all of you i am a student and iam creating an project in java for that i need this. I also want to add File/Folder lock on that project. This technique i have seen in folder lock 6 software that they use hidden drive to store files. Thats why iam asking that how to apply this technique using java.
    And plz plz read this carefully and answer me to solve my problem.

  • How to create and write in a file

    Hello Gurus,
    I am creating a file based on the date and time and writing into that. But, I am still getting exception error and all. Kindly, please let me know.
    thanks for all the help...j
    Error:-
    C:\Usage\JavaFiles>java filename "abc"
    Exception in thread "main" java.io.FileNotFoundException:Detail09-2003-
    03:28:04.doc (The system cannot find the file specified)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:176)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
    at TowerDetail.main(TowerDetail.java:30)
    Code sample:-
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    import java.sql.*;
    import java.text.*;
    public class TowerDetail{
    public static void main (String[] args) throws IOException{
    String userName = "user";
    String passwd = "pwd";
    String con_db = "jdbc:odbc:datasource";
    String ssn = args[0];
    Vector results = new Vector();
    Connection con = null;
    CallableStatement cstmt = null;
    java.util.TimeZone tz = java.util.TimeZone.getTimeZone("EST");
    java.util.Date now = new java.util.Date();
    DateFormat df = new SimpleDateFormat("MM-dd-yyyy-hh:mm:ss");
    df.setTimeZone(tz);
    String result = df.format(now);
    String fileName = "Detail"+result+".doc";
    File inputFile = new File(fileName);
    FileOutputStream fos = new FileOutputStream(inputFile);
    PrintWriter pw = new PrintWriter(fos);
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }catch (Exception e) {
    System.out.println("JDBC Error: "+e.getMessage());
    return;
    try{
    con = DriverManager.getConnection(con_db, userName, passwd);
    cstmt = con.prepareCall("{call dbo.sp_usage_detail(?)}");
    cstmt.setString(1, ssn.trim());
    ResultSet rs = cstmt.executeQuery();
    pw.println("Report "+result);
    pw.println("------------------------------------------------------------------------------------
    while(rs.next()){
    .... write in the file...
    pw.println("------------------------------------------------------------------------------------
    pw.close();
    System.out.println("Your file Detail"+result+".doc is ready!!!");
    cstmt.close();
    con.close();
    }catch(SQLException ex){
    System.out.println("SQLException: ");
    System.out.println(ex.getMessage());
    }catch(NullPointerException e){
    System.out.println("Null Pointer Exception: ");
    System.out.println(e.getMessage());

    Now, I got out of the command prompt and reentered. I didn't set any classpath or anything. I have created a subdir \archive in the C:\ and writing an output file [DetailTower.....doc")into that.
    The DetailTower.class is in C:\Detail\ProjectClass dirctory.
    Now at,
    C:\Detail\ProjectClass\java -classpath . DetailTower "abc"
    I am getting this error:-
    C:\Detail\ProjectClass>java -classpath . DetailTower "999999"
    Exception in thread "main" java.io.FileNotFoundException: c:\archive\DetailTower09-10-2003-06:23:40.doc (The system cannot find the file specified)at java.io.FileOutputStream.open(Native Method)
            at java.io.FileOutputStream.<init>(FileOutputStream.java:176)
            at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
            at Detail.main(DetailTower.java:32)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to create and install a toolbar to a browser using java

    Hi all,
    Can any one guide me about how to create and install toolbar to a browser using java ??
    please any one help me about this,i am not getting any idea about this..
    Thanks and Regards
    Sandesh S

    I doubt you can. Those browser toolbars are done by implementing to an API provided by the browser. That API, I don't believe, is provided via Java. But of course, that would be entirely up to the browser, not Java.

  • How to create and use mutable array of UInt8

    Hello!
    If I get it right, UInt8 *buffer, buffer - is a pointer to a start of array?
    Then how to create and use mutable array of UInt8 pointers?
    The main target is a creation of the module that will store some byte array requests and will send all of them at the propriate moment.

    I try
    - (void) scheduleRequest:(UInt8 *)request {
    if (!scheduledRequests) scheduledRequests = [[NSMutableArray array] retain];
    [scheduledRequests addObject:request];
    But get warning:"passing argument 1 of 'addObject:' from incompatible pointer type"

  • HOW TO CREATE  and  USE EVENTS IN WORKFLOWS .

    HOW TO CREATE  and  USE EVENTS IN WORKFLOWS with the help of classes.
    What i am doing is..
    open se24
    event tab->event name->parameters
    method tab->method name->event handler->copy parameters
    interface tab->if_workflow->enter
    tell me what else to do step by step
    Another important thing is that HOW to use these class events to trigger the workflows.
    REPLY ASAP
    THXS IN ADVANCE

    Hi,
    Pl. see this blog...
    Raising ABAP OO events for workflow
    Regards,
    JOy.

  • How to Create  and use of Coherence servers in weblogic serevr 11g (10.3.6)?

    how to Create  and use of Coherence servers in weblogic serevr 11g (10.3.6)?

    See the below discussion
    How to create and use Webservice controls using WSDL in weblogic portal10.3
    Thanks,
    Venkat Sarvabatla

  • How to create and use dynamic queue in JMS

    Plz tell me how to create and use a dynamic queue in jms and can reciever file lookup it as it lookup any server configurred queue(written in the server).

    Hi,
    We can use Azure File services to do this, for more information, please have a look at this article:
    http://blogs.msdn.com/b/windowsazurestorage/archive/2014/05/12/introducing-microsoft-azure-file-service.aspx. The Azure File service exposes file shares using the standard SMB 2.1 protocol. Applications running in Azure can now easily share files between
    VMs using standard and familiar file system APIs like ReadFile and WriteFile.
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to create and save playlist using JMF?

    Hello i m new to JMF. Can anyone tell me how to create and save a playlist of media files using JMF.
    also how can i play .DAT files using JMF?
    Does JMF supports AVI,Asf files?

    Hello i m new to JMF. Can anyone tell me how to create and save a playlist of media files using JMF.
    also how can i play .DAT files using JMF?
    Does JMF supports AVI,Asf files?

  • How to create and configure proxies in ADF mobile using OWSM client agent?

    Hi
    Can anyone please tell me how to create and configure proxies in ADF mobile application using Oracle Web Services Manager (OWSM) Lite Mobile ADF Application Agent. I read it in mobile document that,
    For secured web services, the user credentials are dynamically injected using ADF Mobile uses Oracle Web Services Manager (OWSM) Lite Mobile ADF Application Agent to create and configure proxies, as well as to request services through the proxies. The user credentials are injected into the OWSM enforcement context when proxies are configured.
    I am new with this OWSM, can anyone please give me some hints like how to proceed further for implementing authentication using OWSM lite mobile ADF Application Agent??
    Thanks in advance
    Raj

    Hi Juan
    The demo is very useful, and in that Shay describes about the remote login using a regular ADF webapplication as a secured one and deploying it into the server. But I would like to know how to create a local login using OWSM client agent? .
    Without creating a regular ADF webapplication, how can i call secured webservices(i.e., by using OWSM client agent how to create and configure proxies to call secured webservice, where the user credentials are injected into webservice request by OWSM client as mentioned in ADF mobile document)??
    Regards
    Raj

  • How do you create and save icc profiles using photoshop?

    How do you create and save icc profiles using photoshop?

    You don't. Color profiles require specific measurement hardware and software.
    Mylenium

  • How to Create and Define New faults to be used inside our BPEL Process

    Hi All,
    I have created a new BPEL process but unable to add fault handling messages which I'm unable to do because I'm not having any
    experience in creating my own custom fault or runtime faults.
    Can anybody can share any URLS of how to create and where to define these things in BPEL Process.
    Expecting a reply from ASAP. very urgent for me.
    Regards,
    CH

    Hi Arik,
    I opening in JDeveloper 11.1.1.2 but it is asking for migrations but not all migrating and unable to see the project.
    By seeing at the logs it is saying that upgrade failed.
    Please can you share any other URL other than this.
    Regards,
    CH

Maybe you are looking for

  • Nokia N95 8 Gigs "The Phone that got forgotten"

    Dear Nokia Support, After I have bought this phone, I was not as please with the price and over all service that I have received from Nokia. I didn't care that it was expensive, but the service... Lets me begin where I have bought this phone for over

  • Problem with uninstalling an extension

    Is there any way to clean up or reset the folders in the component panel? I was experimenting with the "required-restart" attribute in the MXI file and I think that may have caused the problem. A folder exists in my components panel (containing 2 com

  • Why is my iphone not recognizing the sim card

    my iPhone wont pick up the sim card and now I cant get back on my phone to put everything backs

  • How to migrate send mail addressbok

    Hi All , we have sun java messaging server 7.3 directory server 6.2.we have migrated the all mail box send mail messaging server,Now how can we migrate the address book. Regards kamal

  • SG500X Boot Code Update fails (Boot Code too old)

    Hi, I wanted to add an SG500X to an existing stack (Native stacked pure SG500X-Stack) and it always fails, all LEDs on, System LED blinking Amber (according to the Admin Guide this is Hardware failure). The eventlog on the Switch says, that boot code