How to concatinate two clob objects using JDBC...good brain excercise!!!

Hi,
I am using MYSQL server ver. 4.0 and J/Connector version 3.0.6
I have two columns of LONGTEXT type and i have to concatenate them and store it in a third column.I have thought of the following strategy:
1. Retrieve the columns as CLOB using getClob()
2.Concatinate the CLOB values and then insert it in the corr. database column.
My problem is this that i don't know what strategy should i use to concatenate the two values in the clob objects without bringing the whole clob values in the memeory.If i use this strategy..it gives me outofmemory error.
My Clob columns may go upto 10MB in size.
Pl. help.....Any suggestions from the whizkids out there will be extremely appreciated!!!
Thanks....

sorry for replying so late...but neway....
Ok...i will paste a snapshot of my code here....May be that will clarify a few things....
I am opening this in the main function body....To get the first column cell value....
/////////////////Reading the Clob value of the main outer row which will be copmpared with the other rows under it//
BufferedInputStream anInputStream = new BufferedInputStream( rs.getAsciiStream("row_interaction")); //row_intrctn
int aByte = anInputStream.read();
File aFile = File.createTempFile( "tempfile", "txt");
FileOutputStream anOutput = new FileOutputStream(aFile);
while (aByte != -1)
anOutput.flush();
          anOutput.write(aByte);
aByte = anInputStream.read();
Then I depending on some condition i concatenate it with some other cell value from the database ...here i am just concatenating it with another rows column cell clob value..shown below as:
if(loop==0)
String col_string= null;
col_string= convert_bitset_string(temp_b);
//////Getting the other string value///////////////////////////////////////
anInputStream = new BufferedInputStream( rs.getAsciiStream("row_interaction"));
aByte = anInputStream.read();
while (aByte != -1)
anOutput.write(aByte);
aByte = anInputStream.read();
anOutput.flush();
System.out.println("Loop0,2:The "+row_index+"st row being inserted");
////////////////////////Inserting through the prepared statement////////////
String insertion= "Insert into bv"+next_tbl_nm_cntr+" Values(?,?,"+col_string+")";
PreparedStatement pstmt= con.prepareStatement(insertion);
pstmt.setInt(1,row_index);
try{
FileInputStream fis = new FileInputStream(aFile);
pstmt.setAsciiStream(2,fis,(int)aFile.length());
pstmt.execute();
fis.close();
}catch(IOException e)
System.out.println("Error in setting the stream"+e);
System.out.println("Loop0,2:Row inserted");
row_index++;
loop++;
}     //End if: loop=0 i.e the row being inserted is the first row
                              //in the store bitset
Tell me if there is any error because when it concatenates i get some unwanted values too..which i took before in the iteration.....
Any help will be greatly appreciated

Similar Messages

  • How do you retrieve a Collection of objects using JDBC?

    How do you retrieve a Collection of objects using JDBC.
    MORE INFO:
    I have created a class i.e. Account class and I want to retrieve all the accounts previously created for accounts in my Mysql database..
    my method would retrieve an array of Account instances in the database i.e.
    public Vector retrieveAccounts();

    Connection con = null;
    ArrayList accounts = new ArrayList();
    try{
      con = DriverManager.getConnection(...);
      PreparedStatement ps = con.prepareStatement("select * from accounts");
      Resultset rs = ps.executeQuery();
      while (rs.next()) {
        Account account = new Account(rs.getString(1), rs.getString(2), ...);
        accounts.add(account);
      Account[] account_array = new Account[accounts.size()];
      accounts.toArray(account_array);
    catch (SQLException sqle) {
       sqle.printStackTrace();
    finally {
      if (con != null) {
        con.close();
    }should pretty much to what you want, you will obviously need to change it so that, a) the SQL query is correct and b) the Account class is correct and c) the correct values are taken from the result set to create an account.

  • BLOB / CLOB operations using JDBC connections taken from WebLogic 6.0 connectrion pool

    Hi..
    I need to do some CLOB operations using JDBC connection taken
    from WebLogic 6.0 connection pool. Will weblogic 6.0 supports it.?
    I am getting errors when trying to do it in normal way .
    It seems like ResultSet.getClob() returns an RMI (kind of ) object
    instead of the Clob object.
    If you have any idea . Pls respond to [email protected]
    Nazilin

    Hi..
    I need to do some CLOB operations using JDBC connection taken
    from WebLogic 6.0 connection pool. Will weblogic 6.0 supports it.?
    I am getting errors when trying to do it in normal way .
    It seems like ResultSet.getClob() returns an RMI (kind of ) object
    instead of the Clob object.
    If you have any idea . Pls respond to [email protected]
    Nazilin

  • How many messsages can we insert using JDBC receiver adapter in to DB

    Hi Friends,
    We are having 30 JDBC receiver interfaces in my current implementation project; load of JDBC receiver interfaces was 50 k messages per day and Performing only INSERT operation on data base.
    We have created individual communication channel for every JDBC receiver interface and max concurrency value set in CC was 5.
    Now we are testing all interfaces in quality with all possible cases, but we found that JDBC receiver adapter unable to process 50 k messages per day, we are on PI 7.1 EHP1 SP7.
    Please share your experiences with JDBC adapter receiver like per day how many messages we can transfer.
    Thanks a Ton,
    Raj

    Raja Sekhar Reddy T wrote:
    we are processing 50 k individual messages.
    >
    > I have increased max threads for JDBC receiver to 20 but no luck same rate only . My questions here is how many messages we can trasfer using JDBC receiver adapter?
    >
    > Regards,
    > Raj
    Hi raj,
    I have seen some interfaces that deal with upload of 5000 rows at a rime.. I don't there will be a restriction in the no of messages that can be transferred using the JDBC adapter as such  unless until the requirement is so para-normal and in your case it is not
    Kind regards
    XA

  • How to connect Sql Server 2000 using JDBC ODBC Driver

    How to connect Sql Server 2000 using JDBC ODBC Driver ?
    plz Send Syntax.
    thanks

    In SQL Server 2000 the driver class is com.microsoft.jdbc.sqlserver.SQLServerDriver
    The connection URL for the default SQL Server 2000 database is jdbc:sqlserver://localhost:1433
    Class.forName(
      "com.microsoft.sqlserver.jdbc.
      SQLServerDriver");
    String url =
      "jdbc:sqlserver://localhost:1433";
    Connection conn = DriverManager.
      getConnection(
      url, "sa", "sqlserver");

  • How can I remove an object using Photoshop Elements 7?

    How can I remove an object using Photoshop Elements 7?

    You could probably use the 8 point garbage matte in this situation. I personally think the 8-point garbage matte is a bit cumbersome, but it should get the job done.
    1. Use the Razor Blade tool to place a cut before and after the shot with the bottle.
    2. Select the bottle clip.
    3. Press and hold Shift + Option, then drag the bottle clip up one track. This should create a duplicate clip directly above your original clip. (I'll refer to this duplicated clip as bottle2.)
    4. Locate the 8-point Garbage Matte filter and apply it to bottle2.
    5. Locate the Gaussian Blur filter and apply it to bottle2.
    6. Control click bottle1, and uncheck the "Clip Enable" setting from the shortcut menu. This will disable that clip.
    7. Double click bottle2 to load it into the Viewer. Then select the Filter tab.
    8. For the Garbage Matte filter, you'll notice 8 rows of numbers, these are the current locations for the control points, which you should be able to see in the Canvas. Start with point #1, and click the "+" button in the filters area, then in the Canvas click and drag to move the point. When you release the mouse button, you'll need to reclick the "+" button in the filters tab. Repeat these steps until you've isolated the bottle.
    9. Feather the edge of the matte.
    10. Adjust the Blur amount.
    11. Reenable bottle1. Playback the clip and make any necessary adjustments.
    Depending on your experience with Motion, you might also want to try sending bottle1 to Motion, then use Motion to control the layering.

  • How to find a annotation object using plugin API?

    How to find a annotation object using plugin API?

    You would use PDPage methods to find out how many on a page, and to
    get them in turn.
    Aandi Inston

  • How to handle the BOLB column Using JDBC adapter

    Hi,
      I want to sending of a BOLB column from a DB2 database table to another DB2 database, and the sender and receiver both by using JDBC adapter. The two tables in each other database have the same columns.
      Here is the table's structure:
      <ID>string type</ID>
      <PDF>blob type</PDF>
      Also, i haved create two DataTypes in PI system.
      Sender DataType:
      ns:DT_PDF_Req xmlns:ns="http://XXXXX.com/sap/xi">
       <row>
         <ID>1</ID>
         <PDF></PDF>
       </row>
      </ns:DT_PDF_Req>
      Receiver DataType:
      <ns0:DT_PDF_Res xmlns:ns0="http://XXXX.com/sap/xi">
      <STMT>
      <dbtable action="INSERT">
      <table>tablename</table>
      <access>
       <ID></ID>
       <PDF></PDF>
      </access>
      </dbtable>
      </STMT>
      </ns0:DT_PDF_Res>
    When test this interface, i found the that we can get the data, but when execute the insert stms  the follow errors occured  in RWB :
    <ERROR>
    Could not execute statement for table/stored proc. "DBDPUSER.pdf" (structure "STMT") due to com.ibm.db2.jcc.b.nm: DB2 SQL Error: SQLCODE=-103, SQLSTATE=42604, SQLERRMC=255044462d312e330a25c7ec8fa20a352030206f626a0a3c3c2f4c656e677468203620, DRIVER=3.50.153
    JDBC Message processing failed, due to Error processing request in sax parser: Error when executing statement for table/stored proc. 'DBDPUSER.pdf' (structure 'STMT'): com.ibm.db2.jcc.b.nm: DB2 SQL Error: SQLCODE=-103, SQLSTATE=42604, SQLERRMC=255044462d312e330a25c7ec8fa20a352030206f626a0a3c3c2f4c656e677468203620, DRIVER=3.50.153
    </ERROR>
    Can anybody tell me how to resolve the problems?
    And tell me about how to deal BOLB column using PI.
    Best Regards
    Terry

    Hi Terry Qin,
    I understand, you are getting below XML from sender JDBC channel. But when you getting SAX parser error, in receiver JDBC.
    <ns:DT_PDF_Req xmlns:ns="http://XXXXX.com/sap/xi">
    <row>
    <ID>1</ID>
    <PDF></PDF>
    </row>
    </ns:DT_PDF_Req>
    I think it is because the XML which is going to receiver JDBC channel is not well formed (because pdf can containg < & characters).
    You can achive this sceanrio, by selecting receiver JDBC channel as Message Protocol "Native SQL Format" [Link1|http://help.sap.com/saphelp_nwpi711/helpdata/en/44/7c24a75cf83672e10000000a114a6b/frameset.htm] you can send non XML to receiver channel.
    Before that, you have convert above input XML into SQL statement, using Java Mapping.
    Regards,
    Raghu_Vamsee

  • How to compare two date Objects

    Hi,
    I have two Calendar Objects, one is coming from client and one is my server time, I need to evaluate that incoming time with server time so that if it is sent before an hour back then i should not do anything on that request Object. I have converted the incoming String into Calendar Object and how can i evaluate these two Calendar Objects including their hours and minutes.
    Thanks in advance
    bajju

    bajjurireddy, ignore Mobiquity's post. It contains no useful information and will only serve to confuse and frustrate you.
    Mobiquity wrote:
    Also make sure that the two date objects are in the same date format..
    public static String DateToDateString(java.util.Date d, String dateFormat)
         throws ParseException {
              SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
              sdf.setLenient(false); // this is required else it will convert
              String dateString = sdf.format(d);
              return dateString;

  • Reading CLOB data using jdbc thin driver

    Hi,
    When I try reading data for a CLOB column using thin jdbc driver, I get the following error message
    "Exception: ORA-06550: line 1, column 22:
    PLS-00302: component 'GETCHUNKSIZE' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored".
    This error message is displayed when the call is made to get the character stream from the Clob object.
    Do I need to any server side setup before I can access CLOB data from the database?
    thanks.
    Puru Balakrishnan

    I updated to the latest jdbc drivers, 816classes12b.zip, and the problem went away.
    null

  • How to Display two different objects in a single table header in Cross Tab?

    i All,
    I've a reqiurement for a Cross Tab Report like I need two different objects that should be displayed side-by-side, one object's values after another in a single header. In the picture below I've shown the objects separately in two rows, top header having BSNLNL,MTNLNL,RCOMNL and Header-2 having AIRTIL,RCOMIL. But requirements needs to be showing like this,
    BSNLNL
    MTNLNL
    RCOMNL
    AIRTIL
    RCOMIL
    Actually, the data for the header comes from a single object called Operator. I've show the Operators name ending with NL and after that names ending with IL. So, i've separated the data into two variables using the below formulae.
    IL:
    =[Billing Operator]
    Where
    Match([Billing Operator];"*IL")=1
    NL:
    =[Billing Operator]
    Where
    Match([Billing Operator];"*NL")=1
    Also, the NL data should start first and after the NL data's last value ends, the IL data should begin.
    One more thing is that I've to show '0' for null values. So i've used the below formulae on the column data. You can see below that except the "Outgoing ILD Mins in the month from Mobile Network" everything else showing fine. I don't understand why.
    =If
      Substr([Franchise];3;1)="M"
      Then
       [Mobile Outgoing Charged Usage Minutes]
       Else
       0
    I tried different approaches but couldn't find a solution. Could you please help me?     
    I'm using BO WebI 4.1 SP1
    Regards,
    Naren Vema.

    Hi Naren,
    No need to split Billing Operator object. Create a variable-
    V_IL_NL= If  Match([Billing Operator];"*IL")=1 Then "IL" ElseIf Match([Billing Operator];"*NL")=1 Then "NL"
    1) Put V_IL_NL variable below Billing Operator object header.
    2) Sort and create break on this variable.
    3) Delete Footer column. it will automatically create when you apply break.
    4) Hide V_IL_NL variable from this header.
    ~Anuj

  • How to release row lock by using jdbc

    hi, currently we are using jdbc to create a connection and create a row lock , is there anyway to release the row lock? right now i am using resultset.close(), but this cause me problem since it release other resultset's row lock too. please help.

    hi, from your post, i understood that u know how to do row locking..
    How was it done ??
    I'm currently looking for answer to do row locking in Microsoft Access...
    These are the SQL stmt i've done without success..
    SELECT * FROM BSPerson WITH UPDLOCK WHERE ID = 'P001';
    SELECT * FROM BSPerson WHERE ID = 'P001' FOR UPDATE;
    Both stmt having error........
    Please help !
    A miliion thanks....

  • Add new entity object using JDBC Datasource.

    HI my jdev version is 11.1.1.5.0
    I have an adf application with JDBC Datasource connection.
    Now how can I Add a new entity object with JDBC Datasource.How can i connect to DB to map the entity object.
    Thanks

    You need to have a DB connection defined for the project to be able to create new EOs - so just define a new DB connection.
    If you already have ADF BC defined in your application - then it probably means you already have a DB connection defined - see project properties->ADF BC section.

  • Urgent : Problem in passing CLOB object in jdbc call to stored procedure

    i have written a simple program which is enclosed along in which I have insert set value of the CLOB object of a table through the JDBC callablestatement and i m getting error "cannot perform operation with LOB buffering enabled". so please check the code and tell me the solution..
    i u have any other way for doing this please tell
    Thanks in advance
    Atam
    Code follows::::::::::::::::;
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    conn = DriverManager.getConnection("jdbc:oracle:thin:oracle17aug/oracle17aug@dbserver:1521:oracledb");
    cstmt = conn.prepareCall("{call atamp(?)}");
    String strData = "aasdssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssd adad asd asd asd asd";
    byte[] in = new byte[strData.length()];
    in = strData.getBytes();
    if(!strData.equals(""))
    CLOB my_clob = new CLOB((oracle.jdbc.driver.OracleConnection)conn,in);
         my_clob.setLocator(in);
         Writer writer = ((CLOB)my_clob).getCharacterOutputStream();
         writer.write(strData);
         writer.flush();
         writer.close();
         cstmt.setClob(1,my_clob);
    else
    cstmt.setNull(1, java.sql.Types.CLOB);
         cstmt.setQueryTimeout(180);
         cstmt.execute();

    Varghese,
    If the SP has OUT parameters then this impies that the SP is returning to you some response.
    Meanwhile, in your case, if you do not want to catch this response and want to make a Asynch Call, I think you should still create those OUT Parameters in XI. ( Have not given this a shot though ).
    Do update us on the results after you give this a shot.
    Regards
    Bhavesh

  • How to instantiate a java object (using JNI)?(n'more)

    hey bschauwe, thanks for your last post, you were guessing but your 4th guess was right on the money of how id like to do it.
    "4. An alternative way to return data to java from C is to instantiate a java object (using JNI), then use JNI to call that object's setters, then return the object at the end of the C routine."
    I know now how to get the object's setters, I am just unsure how to instantiate a java object from the native C code using JNI. Also you said to returnt he object at the end of the c routine, that is just a good ol' return statement right? no other functions to release memory or anything are needed? So basically it would be something like:
    JNIEXPORT jobject retObj JNICALL Java_AbfaRegion_getJSourceData
      (JNIEnv *env, jobject thisObj)
            //instantiate the java object on retObj????
            //call setters with values from the c structures...
            //return retObj??? no other memory releasing needed?
    }Thanks again for all your help,
    Shane

    K sounds straight forward enough, the index in my book had nothing on <init> and I wasnt aware of the NewObject call. So my final (well for demonstration purposes) code should look something like:
    JNIEXPORT jobject retObj JNICALL Java_AbfaRegion_getJSourceData
      (JNIEnv *env, jobject thisObj)
         jclass clazz;
         jclass clazzTemp;
         jmethodID mid;
         jint val;
         jobject tempObj;
            //first instanciate the object
         clazz = (*env)->GetObjectClass(env, retObj);
         mid  = (*env)->GetMethodID(env, clazz, "<init>", "()V");     
            //Get Object
         tempObj = (*env)->NewObject(env, clazz, mid);
            //get Class reference to instantiated class
         clazzTemp = (*env)->GetObjectClass(env, tempObj);
            //Start calling setters to set the object up.
         mid = (*env)->GetMethodID(env, clazzTemp, "SetHeight", "(I)V");
         (*env)->CallVoidMethod(env,tempObj, mid, struct->myHeight);
            //set more members ...
            //return the object back to java with its members filled out.
            //before returning do I need to call (*env)->DeleteLocalRef(tempObj); ??
            return tempObj;
    }So is this how i do it for a function that is nativly defined as:
    public native JSources getJSourceData();?
    if this is right, then im cooking, and cannot thank you enough!
    -Shane

Maybe you are looking for