STREAMING 을 이용해서 BLOB 에 BINARY DATA 를 저장하는 SAMPLE

제품 : JDBC
작성날짜 : 2003-08-07
STREAMING 을 이용해서 BLOB 에 BINARY DATA 를 저장하는 SAMPLE
============================================================
PURPOSE
STREAMING 을 이용해서 BLOB COLUMN 에 BINARY DATA 를 저장하는
방법을 SAMPLE 을 통해 알아 봅니다.
Explanation
다음 예제는 먼저 blob column 이 들어 있는
MEDIA_STORE 라는 table 을 만들고 그 table 안에
e:\temp\mytest.avi 파일을 insert 하는 내용입니다.
Example
다음을 실행하기 전에 다음명령으로 예제 TABLE 을 생성해야
합니다.
CREATE TABLE MEDIA_STORE ( MNAME VARCHAR2(25),
MTYPE VARCHAR2(15),
MDATA BLOB );
OracleBLOB.java 소스
import java.io.*;
import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.driver.*;
public class OracleBLOB extends Object
Connection conn;
public OracleBLOB()
private void openSession() throws SQLException, Exception
try {
//Register the Oracle JDBC Driver.
Class.forName("oracle.jdbc.driver.OracleDriver");
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//Open a session.
conn = DriverManager.getConnection("jdbc:oracle:thin:@krint-5.kr.oracle.com:1525:ora920","scott","tiger");
} catch(SQLException e) {
e.printStackTrace();
private void insertBLOB() throws SQLException, Exception
BLOB blob;
File binFile;
FileInputStream instream;
OutputStream outstream;
try {
//Set AutoCommit to OFF - required by BLOB locking mechanism.
conn.setAutoCommit(false);
//Create a statement.
Statement stmt = conn.createStatement ();
//Insert an empty BLOB locator.
stmt.execute("INSERT INTO MEDIA_STORE VALUES('THX','DVD-VOB',empty_blob())");
//Execute the query and lock the BLOB row.
ResultSet rset = stmt.executeQuery ("SELECT MDATA FROM MEDIA_STORE WHERE MNAME='THX' FOR UPDATE");
rset.next();
//Get the BLOB locator.
blob = ((OracleResultSet)rset).getBLOB(1);
//Get the large binary media file.
binFile = new File("e:\\temp\\mytest.avi");
instream = new FileInputStream(binFile);
//Insert to the BLOB from an output stream.
outstream = blob.getBinaryOutputStream();
//Read the input stream and write the output stream by chunks.
byte[] chunk = new byte[blob.getChunkSize()];
int i=-1;
System.out.println("Loading");
while((i = instream.read(chunk))!=-1)
{ outstream.write(chunk,0,i); System.out.print('.'); }
//Close the input and output stream.
instream.close();
outstream.close();
//Close the statement.
stmt.close();
} catch(SQLException e) {
e.printStackTrace();
private void closeSession() throws SQLException, Exception
try {
//Close the session.
conn.close();
} catch(SQLException e) {
e.printStackTrace();
public static void main(String[] args) throws SQLException, Exception
OracleBLOB app = new OracleBLOB();
app.openSession();
app.insertBLOB();
app.closeSession();
실행결과 :
E:\temp>java OracleBLOB
Loading
E:\temp>
Reference Documents
Note:95816.1

Similar Messages

  • Need to convert the binary data in blob field to readable format

    Hi,
    We need to convert the Binary data in the BLOB field to readable format and need to display it in Oracle Apps Environment,does anybody come across the similar requirement.
    please advise, thanks in advance.
    Regards,
    Babu.

    You could use standard Attachments functionality here ... if the blob is not in FND_LOBS, insert into FND_LOBS, fnd_attached_documents etc to enable viewing via "Attachments" to the entity the blob is related to.
    Gareth

  • Sample code converting binary data to image file

    Hi experts ,
    I need sample code to convert binary data (bytes) in to an image file.
    any help will be appreciated.
    Thanks and Regards,
    Naresh

    You need to show binary and decimal?  Or now just decimal?
    If binary and decimal, you can right click on your indicator and choose "Display Format...".  If you select the Advanced Editing Mode, you can make soft interesting display formats.  This includes showing the same value in mulitple ways in the indicator.  Try something like "%032b - %d" for the format string.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Exception writing binary data to the output stream to client -Broken pipe

    Hi,
    I am trying to use the drag & drop feature using Contributor mode of Webcenter sites. Single Image Page Attribute is working properly where as Multiple Image Page Attribute throws the following error:
    [ERROR] [.kernel.Default (self-tuning)'] [logging.cs.satellite.request] Exception writing binary data to the output stream to client 10.191.117.106
    java.net.SocketException: Broken pipe
         at java.net.SocketOutputStream.socketWrite0(Native Method)
         at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
         at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
         at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:568)
         at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:539)
         at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:427)
         at weblogic.servlet.internal.ChunkOutput$2.checkForFlush(ChunkOutput.java:648)
         at weblogic.servlet.internal.ChunkOutput.write(ChunkOutput.java:333)
         at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:148)
         at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:148)
         at COM.FutureTense.Servlet.ServletRequest$OutputOutputStream.write(ServletRequest.java:80)
         at COM.FutureTense.Servlet.ServletRequest.write(ServletRequest.java:1633)
         at com.openmarket.Satellite.RequestContext.write(RequestContext.java:1123)
         at com.openmarket.Satellite.BytePiece.stream(DataPiece.java:253)
         at com.openmarket.Satellite.CacheObjectImpl.stream(CacheObjectImpl.java:651)
         at com.openmarket.Satellite.Http11Responder.respondForWrapper(Http11Responder.java:142)
         at com.openmarket.Satellite.WrapperAwareResponder.respond(WrapperAwareResponder.java:36)
         at com.openmarket.Satellite.SatelliteServer.execute(SatelliteServer.java:85)
         at com.openmarket.Satellite.servlet.BaseServlet.doGet(BaseServlet.java:118)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at com.fatwire.wem.sso.cas.filter.CASFilter.doFilter(CASFilter.java:557)
         at com.fatwire.wem.sso.SSOFilter.doFilter(SSOFilter.java:51)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    Thanks
    KarthiK

    Thank u very much,
         FileOutputStream opGif = new FileOutputStream(destFile, false);
    I have changed above line with the following line:
         PrintWriter opGif = new PrintWriter ( new FileWriter(destFile, false));
    and now this code is working very fine.
    Thanks once again...

  • Conversion of a binary data stream to decimal numbers

    Hi
    I am having great difficult working out how to convert my binary data stream to decimal numbers.
    The data I am reading back is in the format of a binary string, starting with the Most Significant Bit (MSB) of the first word, then the corresponding Least Significant Bit (LSB), where a word is two bytes long. A carriage return indicates message termination.  The return message starts with ‘bin,’ followed by the number of bytes requested. No delimiters are used to separate the data, but a carriage return is appended onto the end of the data.
    bin,<first word msb><first word lsb>...<last word lsb><CR>
    e.g. bin,$ro¬z1;@*...etc
    Does anybody know of any examaple vi that can help me convert this data from binary to decimal numbers?
    Many Thanks
    Ash

    Hi Ashley,
    after getting the string you can strip the first 4 characters. After this try a typecasting to array of U16. If the numbers are not correct, you can add a swap bytes operation to the resulting array.
    Message Edited by GerdW on 09-13-2006 02:46 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    Convert.png ‏2 KB

  • Data plug-in for binary data with byte streams of variable length

    Hi there,
    I would like to write a data plug-in to read binary data from file and I'm using DIAdem 10.1.
    Each data set in my file consists of binary data with a fixed structure (readable by using direct access channels) and of a byte stream of variable length. The variable length of each byte stream is coded in the fixed data part.
    Can anyone tell me how my data plug-in must look like to read such kind of data files?
    Many thanks in advance!
    Kind regards,
    Stefan

    Hi Brad,
    thank you for the very quick response!
    I forgot to mention, that the data in the byte stream can actually be ignored, it is no data to be evaluated in DIAdem (it is picture data and the picture size varies from data set to data set).
    So basically, of each data set I would like to read the fixed-structure data (which is the first part of the data set) and discard the variable byte stream (last part of the data set).
    Here is a logical (example) layout of my binary data file:
    | fixedSize-Value1 | fixedSize-Value2 | fixedSize-Value3 (=length of byte stream) | XXXXXXXXXXXXX (byte stream)
    | fixedSize-Value1 | fixedSize-Value2 | fixedSize-Value3 (=length of byte stream) | XXXXXX (byte stream)
    | fixedSize-Value1 | fixedSize-Value2 | fixedSize-Value3 (=length of byte stream) | XXXXXXXXXXXXXXXXXXXX (byte stream)
    What I would like to show in DIAdem is only fixedSize-Value1 and fixedSize-Value2.
    ´
    If I understood right, would it be possible to set the BlockLength of each data set by assigning Block.BlockLength = fixedSize-Value3 and to use Direct Access Channels for reading fixedSize-Value1 and fixedSize-Value2 ?
    Thank you!
    Kind regards,
    Stefan

  • PbyFwData - Pointer to the firmware binary data stream.

    Hello,
    I used labview to call a dll, but it have one parameter "pbyFwData" which Pointer to the firmware binary data stream.i don't understand what mean is "Pointer to the firmware binary data stream".I try to make this parameter point to the firmware path, but the program can't be run.the below is the .dll source code. who can tell you how to pass the value to the parameter "pbyFwData" by labview?
    // Purpose:      Public function to download the Flash Preloader.
    // Parameter:
    //   hZvDev    - Handle of the Zeevo Device.
    //   pbyFwData - Pointer to the firmware binary data stream.
    //   uFwLen    - The length of the preloader.
    // Return value: SUCCESS if successful; Otherwise, the error code.
    ZEEVOPTU_API int ZV4301_SendPreLoader(HANDLE hZvDev,
                                          unsigned char *pbyFwData,
                                          unsigned long uFwLen)
       ZV4301 *pZvDev;
       COMM_DESC *pPort;
       int nResult, nTmOut;
       const unsigned long uBlkSize = 0x400;
       unsigned long uDummy, uCRC;
       unsigned char byDataBuf[32];
       unsigned char byData;
       if (!Validate(hZvDev))
          return ERR_BAD_HANDLE;
       pZvDev = (ZV4301 *)hZvDev;
       pPort = pZvDev->PortDesc;
       // Setup the Address and Length
       memset(byDataBuf, 0, sizeof(byDataBuf));
       LD_LoaderProgramAddr(byDataBuf) = LD_ZV4301_LOADER_ADDR;
       LD_LoaderProgramLengh(byDataBuf) = uFwLen;
       // Calculate the Header CRC
       uCRC= UT_CRCBuffer(byDataBuf+4, 8);
       LD_LoaderProgramHdrCRC(byDataBuf) = uCRC;
       // Calculate the Data CRC
       uCRC = CalculateCRC(pbyFwData, uFwLen);
       LD_LoaderProgramDataCRC(byDataBuf) = uCRC;
       // Detect target reset
       nResult = IsChipPwrOnReset(pZvDev, 10000);
       if (nResult != SUCCESS)
          return nResult;
       // send out header first
       nResult = WriteSerial(pZvDev, byDataBuf, LD_LOADER_PRGM_HDR_LEN);
       if (nResult != SUCCESS)
          return nResult;
       while (uFwLen > 0)
       {  // sending the preloader file
          if (uFwLen >= uBlkSize)
             nResult = WriteSerial(pZvDev, pbyFwData, uBlkSize);
             pbyFwData += uBlkSize;
             uFwLen -= uBlkSize;
          else
             nResult = WriteSerial(pZvDev, pbyFwData, uFwLen);
             uFwLen = 0;
          if (nResult != SUCCESS)
             return nResult;
       nTmOut = 100;
       while (nTmOut > 0)
       {  // getting the respond 0xAA
          if (GetByte(pZvDev, &byData))
             if (byData == 0xAA)
                break;
          Sleep(10);
          nTmOut -= 10;
       if (nTmOut == 0)
          return ERR_DOWNLD_PRELDR;
       nResult = SetCommBaud(pZvDev, FLOWCTRL_DIS, pPort->uBaud, &uDummy);
       return nResult;

    Hi,
    The pointer is a U32 that points to a memory location where the data is. It is not clear from the prototype whether the pointer points to data that is feeded to the dll, or returned from the dll.
    If data is feeded, wire an array to this parameter, and set uFwLen to it's length.
    If data is returned, you need to use some other api calls to get the data from memory...
    Regards,
    Wiebe.
    "Jimmy168" <[email protected]> wrote in message news:[email protected]...
    Hello,I used labview to call a dll, but it have one parameter "pbyFwData" which Pointer to the firmware binary data stream.i don't understand what mean is "Pointer to the firmware binary data stream".I try to make this parameter point to the firmware path, but the program can't be run.the below is the .dll source code. who can tell you how to pass the value to the parameter "pbyFwData" by labview?
    &nbsp;
    //------------------------------------------------------------------------------// Purpose:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Public function to download the Flash Preloader.// Parameter://&nbsp;&nbsp; hZvDev&nbsp;&nbsp;&nbsp; - Handle of the Zeevo Device.//&nbsp;&nbsp; pbyFwData - Pointer to the firmware binary data stream.//&nbsp;&nbsp; uFwLen&nbsp;&nbsp;&nbsp; - The length of the preloader.// Return value: SUCCESS if successful; Otherwise, the error code.//------------------------------------------------------------------------------ZEEVOPTU_API int ZV4301_SendPreLoader(HANDLE hZvDev,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned char *pbyFwData,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned long uFwLen){ &nbsp;&nbsp; ZV4301 *pZvDev;&nbsp;&nbsp; COMM_DESC *pPort;&nbsp;&nbsp; int nResult, nTmOut;&nbsp;&nbsp; const unsigned long uBlkSize = 0x400;&nbsp;&nbsp; unsigned long uDummy, uCRC;&nbsp;&nbsp; unsigned char byDataBuf[32];&nbsp;&nbsp; unsigned char byData;
    &nbsp;&nbsp; if (!Validate(hZvDev))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ERR_BAD_HANDLE;&nbsp;&nbsp; pZvDev = (ZV4301 *)hZvDev;&nbsp;&nbsp; pPort = pZvDev-&gt;PortDesc;
    &nbsp;&nbsp; // Setup the Address and Length&nbsp;&nbsp; memset(byDataBuf, 0, sizeof(byDataBuf));&nbsp;&nbsp; LD_LoaderProgramAddr(byDataBuf) = LD_ZV4301_LOADER_ADDR;&nbsp;&nbsp; LD_LoaderProgramLengh(byDataBuf) = uFwLen;&nbsp;&nbsp; // Calculate the Header CRC&nbsp;&nbsp; uCRC= UT_CRCBuffer(byDataBuf+4, 8);&nbsp;&nbsp; LD_LoaderProgramHdrCRC(byDataBuf) = uCRC;&nbsp;&nbsp; // Calculate the Data CRC&nbsp;&nbsp; uCRC = CalculateCRC(pbyFwData, uFwLen);&nbsp;&nbsp; LD_LoaderProgramDataCRC(byDataBuf) = uCRC;&nbsp;&nbsp; // Detect target reset&nbsp;&nbsp; nResult = IsChipPwrOnReset(pZvDev, 10000);&nbsp;&nbsp; if (nResult != SUCCESS)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return nResult;&nbsp;&nbsp; // send out header first&nbsp;&nbsp; nResult = WriteSerial(pZvDev, byDataBuf, LD_LOADER_PRGM_HDR_LEN);&nbsp;&nbsp; if (nResult != SUCCESS)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return nResult;
    &nbsp;&nbsp; while (uFwLen &gt; 0)&nbsp;&nbsp; {&nbsp; // sending the preloader file&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (uFwLen &gt;= uBlkSize)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nResult = WriteSerial(pZvDev, pbyFwData, uBlkSize);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pbyFwData += uBlkSize;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uFwLen -= uBlkSize;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nResult = WriteSerial(pZvDev, pb

  • [svn:osmf:] 14486: Add stream metadata support by extracting the actual metadata object from the binary data stream .

    Revision: 14486
    Revision: 14486
    Author:   [email protected]
    Date:     2010-03-01 14:27:41 -0800 (Mon, 01 Mar 2010)
    Log Message:
    Add stream metadata support by extracting the actual metadata object from the binary data stream.
    Fix bug 466
    Modified Paths:
        osmf/trunk/framework/OSMF/org/osmf/elements/f4mClasses/ManifestParser.as
        osmf/trunk/framework/OSMF/org/osmf/elements/f4mClasses/Media.as
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/HTTPStreamingUtils.as
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/f4f/HTTPStreamingF4FIndexHandler.as
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/f4f/HTTPStreamingF4FStreamInfo.as

    same problem, data not replicated.
    its captured,propagated from source,but not applied.
    also no apply errors in DBA_APPLY_ERROR. Looks like the problem is that LCRs propagated from source db do not reach target queue.can i get any help on this?
    queried results are as under:
    1.at source(capture process)
    Capture Session Total
    Process Session Serial Redo Entries LCRs
    Number ID Number State Scanned Enqueued
    CP01 16 7 CAPTURING CHANGES 1010143 72
    2. data propagated from source
    Total Time Executing
    in Seconds Total Events Propagated Total Bytes Propagated
    7 13 6731
    3. Apply at target(nothing is applied)
    Coordinator Session Total Total Total
    Process Session Serial Trans Trans Apply
    Name ID Number State Received Applied Errors
    A001 154 33 APPLYING 0 0 0
    4. At target:(nothing in buffer)
    Total Captured LCRs
    Queue Owner Queue Name LCRs in Memory Spilled LCRs in Buffered Queue
    STRMADMIN STREAMS_QUEUE 0 0 0

  • Streaming Binary Data

    Hi,
    I would like to send plain old binary data using RTP. How can I use the JMF to send binary data without binding it to a codec or media type?
    Thanks,

    sam8680 wrote:
    I would like to send plain old binary data using RTP. How can I use the JMF to send binary data without binding it to a codec or media type?Is there a particular reason you don't want to use a normal UDP or IP socket for plain old binary data?

  • Writing binary data to ASP file from applet through URLConnection

    Hi Everybody,
    I am facing a proble with HttpURLConnection.I want to write some binary data from applet to an ASP file.The other end ASP file read this binary data and process , Here problem is I have opened URLConnection to the page and Created OutputStream and writing byte by Write() method But other end we are not getting bytes...we are not getting error too at java side..can any body help me..do we need to set any property to URLConnection...here I am giving sample code...
    OutputStream os;
    URL uConnect2;
    HttpURLConnection hucConnect2;
    uConnect2= new URL("http://webserver/vnc/sendtoserver.asp?"); hucConnect2=(HttpURLConnection)uConnect2.openConnection();
    hucConnect2.setDoOutput(true);
    hucConnect2.setRequestMethod("POST")
    os=new DataOutputStream(hucConnect2.getOutputStream());
    os.writeBytes("Hello");
    Thanks in Advance
    Madhav

    Do you remember to flush() and close() the stream?

  • Adapter development: binary data and adapter specific properties?

    Hi,
    We have succesfully developed our own SFTP adapter based on the J2SSH Maverick library (http://www.sshtools.com/showMaverick.do) and the sample file adapter that comes with XI.
    There are 2 features we would like to implement as well, but lack the necessary documentation and sample code.
    <b>1st Binary data</b>
    We do not succeed in transporting binary data via our SFTP adapter (both text and xml go fine).  While debugging, we see that the binary data are correctly picked up, but the actual payload appearing in message monitoring is much larger.  When we write the message to a file again, the data have changed (size has e.g. increased importantly from 127180 bytes to 218198 bytes).  According to the sample adapter code,  the contenttype "application/octet-stream"  should be specified.  But the standard XI file adapter itself seems to specify "application/octet-stream".
    <b>2nd Adapter specific properties (DynamicConfiguration)</b>
    How can we set adapter specific properties in our own adapter code?  Where are the Java docs of the API?  Is this somewhere documented?
    If you would have more information (or pointers), please post it as a response to this message.
    Kind regards, Guy Crets
    <b>Code snippet:</b>
    XIMessageFactoryImpl mf = new XIMessageFactoryImpl();
    Message msg = mf.createMessageRecord(fromParty, toParty, fromService, toService, action, actionNS);
    msg.setDeliverySemantics(DeliverySemantics.ExactlyOnce);
    // In case of XML documents it is not necessary to set the contentType or encoding
    // But: take care that the encoding definiton in the XML document corresponds to the encoding used
    if (msgText.indexOf("<?xml") != -1)
      // Check whether the payload is a XML document. If not, treat it as binary to demonstrate how
      // binary main documents work
      // First create a XML Payload                    
      XMLPayload xp = null;
      xp = msg.createXMLPayload();
      xp.setText(msgText);
      xp.setName("MainDocument");
      xp.setDescription("XI AF Sample Adapter Input: XML document as MainDocument");
      msg.setDocument(xp);
    // In case of binary documents use the Payload super class methods to fill the XMLPayload object
    else
      // Check whether the payload is a XML document. If not, treat it as binary to demonstrate how
      // binary main documents work
      // First create a XML Payload                    
      XMLPayload xp = null;
      xp = msg.createXMLPayload();
      //xp.setContentType("application/octet-stream");
      xp.setContentType("application/xml");
      xp.setName("MainDocument");
      xp.setDescription("XI AF Sample Adapter Input: Binary as MainDocument");
      xp.setContent(msgData);
      // Finally set the main document in the message
      msg.setDocument(xp);          
    TRACE.debugT(SIGNATURE, XIAdapterCategories.CONNECT_AF, "Message object created and filled.");
    ModuleData md = new ModuleData();
    md.setPrincipalData(msg);

    Hello Moorthy,
    I know this part of the documentation.
    So I set the indicator within the communication channel.
    Now, I have to fill the dynamic configuration during my mapping. My code looks like following:
    DynamicConfigurationKey keyURL =  DynamicConfigurationKey.create("http://sap.com/xi/XI/System/HTTP", <b>XXXXX</b>);
    // access dynamic configuration
    DynamicConfiguration conf = (DynamicConfiguration) param.get (StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    // set value
    conf.put(keyURL, url);
    So what has to be filled instead of XXXXX ?
    Regards,
      Marc

  • How to receive the images / binary data t ype

    How to receive the images / binary data type in webdynpro....
    i have a website that let's the user send email, the email attachment and message are stored in both in images data type....
    q1) can i stored the message into binary data type...but the message is very long.....
    q2) if i have a textbox ...i surely will need to display the message  in string ,right ?
    [......... msg here ........]
    what is the codes to receive the images / binary data type in webdynpro....

    As in your previous post if you are storing them as BLOB object.. am sure you are able to get a byte stream or byte array(bytes[]) out of it.
    There should be some way to identify if its a image or a message BLOB. If its a image , convert into bytes and use 
       WDWebResource.getWebResource(bytes,resource type).getAbsoluteURL()
    to obtain the url.. assign this image UI element..
    In case its the message , use bytes.toString to get the message ..
    Regards
    Bharathwaj

  • Reading the binary data from a http request received via socket connection.

    1. I require to extract the binary data out of a http multipart request,
    2. I have a server socket opened up, which can receive connections over tcp( and therefore http.)
    3. I will require to read the stream, find out the "request boundary identifier", and then extract the different "request body parts".
    4. From there i need to read all of the binary content and put it in a file.
    5. I did some implementation to his effect. but i see that the file that i had uploaded initially if its not a text file, gets corrupted.
    can you please let me know why is that happening, and a probable solution approach.
    please find below the class (with a main method) I have been using to expose a server socket.
    package self.services;
    import java.io.BufferedReader;
    import java.io.ByteArrayOutputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.io.PrintWriter;
    import java.net.ServerSocket;
    import java.net.Socket;
    public class FileServer {
         public static void main(String[] args) throws Exception {
              ServerSocket serverSocket = new ServerSocket(9999);
              String FOLDER_NAME = "uploaded_files";
              while(true) {     
                   try{
                        Socket socket = serverSocket.accept();
                        InputStream is = socket.getInputStream();
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
                        String currentLine;
                        int cnt = 0;
                        boolean postRequest = false;
                        String dataBoundary = null;
                        String fileName = null;
                        String yourName = null;
                        while((currentLine = reader.readLine()) != null) {
                             if(currentLine.contains("POST")) {
                                  postRequest = true;
                                  System.out.println("POST REQ AS EXPECTED VERY NICE");
                                  continue;
                             if(!postRequest) {
                                  System.out.println("NO POST REQ THIS BREAKING FLOW");
                                  break;
                             } else {
                                  if(currentLine.contains("Content-Type: multipart/form-data; boundary=")) {
                                       System.out.println("found a boundary value header");
                                       dataBoundary = currentLine.substring((currentLine.indexOf("boundary=") + "boundary=".length()), (currentLine.length() -1));
                                       System.out.println("boundary value = ".concat(dataBoundary));
                                       continue;
                                  if(dataBoundary != null && currentLine.contains(dataBoundary)) {
                                       cnt++;
                                  if(cnt == 1) {
                                       //move 3 lines
                                       if(currentLine.contains("Content-Disposition: form-data; name=\"yourName\"")){
                                            reader.readLine();//skip a line
                                       System.out.println("Your name = ".concat(yourName = reader.readLine()));
                                       continue;
                                  } else if(cnt == 2) {
                                       if(currentLine.contains("Content-Disposition: form-data; name=\"sentFile\"; filename=\"")){
                                            fileName = currentLine.substring(currentLine.indexOf("filename=") + "filename=".length() + 1, currentLine.length() - 1);
                                            System.out.println("File Name = ".concat(fileName));
                                            reader.readLine();//skip a line , this would depict a content type header
                                            reader.readLine();//skip a line, this would indicate a blank line to mark the start of data.
                                            continue;
                                       } else {
                                            // write the content to os
                                            if(currentLine != null && !currentLine.contains(dataBoundary)) {
                                                 baos.write(currentLine.concat("\r").getBytes());
                                  } else if( cnt == 3) {
                                       System.out.println(("cnt [" + cnt).concat( "], current line [").concat(currentLine).concat("]"));
                                       break;
                        if(fileName == null ||yourName == null) {
                             System.out.println("FileServer.main() dont bother about this" );
                        } else {
                             //send a response back
                             PrintWriter pw = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
                             pw.write(responseMessage(yourName, fileName));
                             pw.flush();
                             //close output stream
                             pw.close();
                             //handle the request bytearray.
                             FileOutputStream fos = new FileOutputStream(FOLDER_NAME + "/" + fileName);
                             fos.write(baos.toByteArray(), 0, baos.toByteArray().length - 1);
                             fos.close();
                        //close input stream
                        reader.close();
                        socket.close();
                        baos.close();
                   } catch(Exception ex) {
                        ex.printStackTrace();
         public static String responseMessage(String yourName, String fileName) {
              String response =
                   "<HTML>" .concat(
                   "<BODY>") .concat(
                   "<P>" ).concat(
                   "Mr. <FONT color=\"red\">") .concat( yourName).concat("</FONT>. Your file named <B>").concat( fileName).concat( "</B> successfully reached us." ).concat(
                   "</P>") .concat(
                   "</BODY>").concat(
                   "</HTML>");
              return response;
    }{code}
    Here is a sample html file which can be used to send multipart requests to the java service.
    <html>
         <body>
              <form action="http://localhost:9999" enctype="multipart/form-data" method="POST">
                   Enter name :<br/>
                   <input type="text" name="yourName"/>
                   Enter file :<br/>
                   <input type="file" name="sentFile"/>
                   <br/>
                   <input type="submit" value="Submit"/>
              </form>
         </body>
    </html>
    *Both the form elements are mandatory*
    *I hope my requirement is clear. Any help regarding this will be highly appreciated.*
    Regards.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    MishraC wrote:
    1. I require to extract the binary data out of a http multipart request,
    2. I have a server socket opened up, which can receive connections over tcp( and therefore http.)
    3. I will require to read the stream, find out the "request boundary identifier", and then extract the different "request body parts".
    4. From there i need to read all of the binary content and put it in a file.
    5. I did some implementation to his effect. but
    i see that the file that i had uploaded initially if its not a text file, gets corrupted.
    can you please let me know why is that happening,Because you are using a Reader (which translates bytes to chars according to the charset encoding specified).
    and a probable solution approach. Use a BufferedInputStream.

  • Stored Procedure w/ binary data parameter problems in Visual Basic

    Howdy all.
    I am having a problem calling stored procedures with a BLOB parameter. I have tried changing the paramater other data types to see if it would work, but with no success. I am calling the stored procedure from Visual Basic using ADO. I am using the Oracle ODBC Driver, Release 9.2.0.4.0. I have tried changing the setup of the ODBC a good bit because that has fixed several problems for me in the past; however, it did not fix my current problem.
    Here is what I am trying to do. I have a function like the folowing:
    <BEGIN --------------------------------------->
    CREATE OR REPLACE FUNCTION PAGEFORMATSINSERT(
    p_ObjectFormatCode_ID      IN RAW DEFAULT NULL,
    p_PA_ID      IN RAW DEFAULT NULL,
    p_Name      IN VARCHAR2 DEFAULT NULL,
    p_FormatData      IN BLOB DEFAULT NULL,
    p_PF_ID      IN OUT RAW )
    RETURN INTEGER
    AS
    BEGIN
    INSERT INTO PAGEFORMATS (PF_ID, ObjectFormatCode_ID, PA_ID, Name, FormatData) /* <---- this FormatData column is a BLOB column */
    VALUES     (p_PF_ID, p_ObjectFormatCode_ID, p_PA_ID, p_Name, p_FormatData)
    END PAGEFORMATSINSERT;
    <END ----------------------------------------->
    The FormatData parameter has a data type of BLOB. In my Visual Basic, I have my ADODB.Command object. I am setting the CommandText of the Command object to "{? = call PageFormatsInsert(?, ?, ?, ?, ?)}". In order to set the parameter value for the BLOB data type, I am calling the AppendChunk function of the Command object - passing it a Byte array.
    I am getting the folling error:
         ERROR: -2147467259 [Oracle][ODBC][Ora]ORA-06550: line 1, column 13:
         PLS-00306: wrong number or types of arguments in call to 'PAGEFORMATSINSERT'
         ORA-06550: line 1, column 7:
         PL/SQL: Statement ignored
    If I change the FormatData parameter to a LONG RAW parameter, I get the following error:
         ERROR: -2147467259 [Oracle][ODBC][Ora]ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error
         ORA-06512: at line 1
    I am at a loss as to how to get binary data into by Oracle database. I need to do it using stored procedures. How can I set up my stored procedure or table to do what I want it to do? Should I change my table definition? Are there some settings in the ODBC connection I can tweak? How can I get the stored procedure to accept my call from VB ADO?
    Any help would be appreciated.
    wally

    Thanks for the idea, but I don't get how I am supposed to get my binary data to the stored procedure using the stream. I have a binary array that I want to pass to a stored procedure. I want to be able to use the same Visual Basic front end with out MSSQL database as with our Oracle database.
    I am using the ADODB Connection and Command and RecordSet objects. Currenlty our front end calls the ADODB.Command(ParamNumber).AppendChunk function passing it the binary array. Somehow, the SQL Server driver does the magic in order for the MSSQL stored procedure to work correctly. I need to know how to do one of the following:
    1. Get the Oracle driver to do the same magic.
    2. Set up the Oracle stored procedure so I don't have to change the VB front end.
    3. Change the VB front end so that it works with both MSSQL and Oracle.
    wally

  • Using a servlet to send binary data

    There is a section of our intranet that need to hold documents that have to be available only for a certain group of users. Here's my approach (if you think of a better one, please tell me):
    1-all the files are in a directory upper than WWWRoot so that nobody can directly download them
    2-there is a servlet that first: authentificate the user with username-password; and then lists all available documents.
    3-When one of these docs is clicked, I want my servlet to open the file using filesystem File object and then copy the content of the selected file in the http response body. What object and method should I use to do so? I dont know if I should use FileReader or something else. Dont forget it will not only has to work with text files, but also with binary data files like swf, powerpointpresentation and the like. So I fear that objects such as FileRead will mess special characters up and corrupt data.
    What would you advice me? Use FileReader or another object? Or maybe a completly different approach for the problem? And if you want to give me some sample codes, it would be appreciated.
    Thx for your help

    There is something I dont understand.. its bizarre. Usually I dont understand why a script is not working, but now, I dont understand why a scritp is working..
    Here are the codes that copy from a file to the servlet's ouput:
    //basic response configurations
    response.setContentType( mimeType );
    ServletOutputStream out = response.getOutputStream();
    //copy a file f to the servlet's output stream
    File f = new File( path );
    FileInputStream fis= new FileInputStream(f);
    int available = fis.available();
    byte[] b = new byte[available];
    fis.read(b);
    out.write( b );
    out.flush();
    They work fine. What I dont understand is that I tried them with a file of about 5 megs, and they still worked! I expected them to fail because the variable available is of the type int and then it implies that the maximum file size permitted by the algorithm should be 65536 bytes/1024=64 ko... isn't it????

Maybe you are looking for

  • Using Windows Media Player to transfer fi

    Hello all! This is my first post to the forum. I received a Nomad Jukebox Zen Xtra 60GB for Christmas and have encountered a few problems. I am using WMP for transfering files to the player and after during the transfer of the 5th album, the last fi'

  • How to read the blob column?

    Hi, i wanted to store the zip file in a blob column and i also want to download the file i have tried in the following manner -- Creation of the table create table demo ( ID int, theblob blob); --insert the zip file into the table declare l_blob blob

  • How to used BAPI_SALESORDER_CHANGE to add items

    Hi, I am trying to use the above bapi to add items to a sales order, but I can't get the qty to map across.  I had the same problem using the create bapi whcih I resolved by populating the schedule tables, but in change this just causes an "unhandled

  • ITunes marks part-played podcasts as played!!

    I just got a 5th gen iPod and while the new feature (for me) of remembering where you left off in a podcast and being able to pick up where you left off it very useful, I've also noticed another, annoying change. I have my iPod preferences set in iTu

  • Can a server handle threads?

    I have a server that a) recieves data b) updates a database c) sends data to clients I tried putting the database update into a separate thread : Runnable task = new Runnable() { public void run() { //i have a print statement here //which is not reac