Iterator vs. ResultSet

Hi all,
I need some help on this topic. How can I access the database with an Iterator pattern instead of using ResultSet.next()? If we use Iterator, will the data still be availble even if the connection to database closed?
Thanks in adv
chanh

Iterator and ResultSet aren't really comparable. An Iterator typically represents an internally contained collection of elements (that are retrieved iteratively). A ResultSet represents an iterative (or normally iterative) access to a table view in some database. In other words, the ResultSet just really holds connectivity information on how to get the specific data, but not the actual data, while an Iterator 'holds' its data internally (hence ResultSet's close method, or why ResultSets are not Serializable).
If you want to access the data beyond the connection, you need to populate some other java class (which could be an Iterator) via the ResultSet. I'm sure there are resources available on the net, that are nothing more then ResultSet wrappers like you are describing (like populating some Iterator implementation via a ResultSet- it propably even has the getXXX methods that the previous poster talks about). Try searching the forums or maybe google- I would think you can find some thing.

Similar Messages

  • Iterating through resultset - help

    Hello.
    I have a resultset which contains the following records:
    type=a, name=name1, dateupdate = 4/1/2005
    type=b, name=name1, dateupdate=4/2/2005
    type=c, name=name1, dateupdate=4/1/2005
    type=d, name=name1, dateupdate=4/1/2005
    type=a, name=name2, dateupdate=3/31/2004
    type=c, name=name2,dateupdate=3/31/2004
    I need to iterate through the resultset to check that all types (a,b,c,d) exists for each name.
    What's the best way to do this?
    Thanks.

    Hello.
    I have a resultset which contains the following
    records:
    type=a, name=name1, dateupdate = 4/1/2005
    type=b, name=name1, dateupdate=4/2/2005
    type=c, name=name1, dateupdate=4/1/2005
    type=d, name=name1, dateupdate=4/1/2005
    type=a, name=name2, dateupdate=3/31/2004
    type=c, name=name2,dateupdate=3/31/2004
    I need to iterate through the resultset to check that
    all types (a,b,c,d) exists for each name.
    What's the best way to do this?
    Thanks.pseudo-code:
    typeCount = 0
    prevName = null
    while (more rows)
      get next row
      if name == prevName
        ++typeCount
      else
        checkStats(prevName, typeCount)
        prevName = name
        typeCount = 1
      end-if
    end-while
    checkStats(prevName, typeCount)checkStats would check that typeCount is 4 and if it isn't, do whatever you want to do for that prevName to alert that it didn't have all 4 types. The pseudo-code also assumes that your resultset is ordered by name, and that it can't contain duplicate types or types outside the range a-d.

  • Knowing row-count withour iterating resultset

    Is there any way of knowing the
    row-count of a resultset without
    ever iterating the resultset?

    quite simply - NO.
    only you can have a boolean
    that can tell you whether or not
    your resultset had any rows.
    boolean isEmpty = true;
    while(rs.next())
         isEmpty = false;
    }//Check for isEmpty to know whether
    there was anything anywayz...

  • Sybase stored proc, no rows in the resultset

    Hi!
    I have a sybase stored proc that looks more like -
    IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
    BEGIN
    DROP PROCEDURE dbo.ETC_DETAILS
    IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
    PRINT '<<< FAILED DROPPING PROCEDURE dbo.ETC_DETAILS >>>'
    ELSE
    PRINT '<<< DROPPED PROCEDURE dbo.ETC_DETAILS >>>'
    END
    go
    CREATE PROCEDURE dbo.ETC_DETAILS
    @trade_id id,
    @broker_cd code,
    @contact_group_id int,
    @product_id id,
    @security_type_id smallint
    AS
    if(cond1)
    begin
         select distinct
    cd=t.cd,
    name=t.name,
    t.trade_id,..........
         from
         table1 t,
         table2 tt,
         table3 b,.......
         where t.trade_id = tt.trade_id
         and t.transaction_type_id = ttt.transaction_type_id
         and .....
    end
    else
    select distinct
    cd=t.cd,
    name=t.name,
    t.trade_id,..........
         from
         table4 t,
         table5 tt,
         table6 b,.......
         where t.trade_id = tt.trade_id
         and t.transaction_type_id = ttt.transaction_type_id
         and .....
    end
    go
    GRANT EXECUTE ON dbo.ETC_DETAILS TO public
    go
    IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
    PRINT '<<< CREATED PROCEDURE dbo.ETC_DETAILS >>>'
    ELSE
    PRINT '<<< FAILED CREATING PROCEDURE dbo.ETC_DETAILS >>>'
    go
    EXEC sp_procxmode 'dbo.ETC_DETAILS','unchained'
    go
    GRANT EXECUTE ON dbo.dbo.ETC_DETAILS TO public
    go
    When run through SQL Editor - runs and returns me rows. But does not return any rows when invoked from Java. "gotResultSet" is true, but the while loop does not execute. Any clues, why? Here is the Java code.
    public class AllocationExtractor {
         public Collection getAllocations(int tradeId, String brokerCode, int contactGroupID, int productID, int securityTypeID) throws SQLException
              Connection c = null;
              String query = "{ call ETC_DETAILS(?,?,?,?,?) }";
              CallableStatement stmt = null;
              ResultSet rs = null;
              boolean gotResults = false;
              try{     
                   c = ConnectionFactory.getSybaseConnection(url, user, pwd);
                   stmt = c.prepareCall(query);
                   stmt.setInt(1, tradeId);
                   stmt.setString(2, brokerCode);
                   stmt.setInt(3, contactGroupID);
                   stmt.setInt(4, productID);
                   stmt.setInt(5, securityTypeID);
                   gotResults = stmt.execute();
                   if(gotResults)rs = (ResultSet) stmt.getResultSet();
                   if (rs != null){
                        System.out.println("Got resultSet");
                   while(rs.next()){
                        System.out.println("Iterating the resultset");
                        Allocation a = new Allocation();
                        a.setTradeID(rs.getString("trade_id"));
                        System.out.println(a.getTradeID());
                        allocations.add(a);
         public static void main(String args[]){
              AllocationExtractor e=new AllocationExtractor();
              Collection c = null;
              int tradeID = 3115;
              String broker_cd = new String("327");
              int product_id = 20;
              int contact_group_id = 1;
              int security_type_id = 1219;
              e.user = "developer";
              e.url = "jdbc:sybase:Tds:devbox:12344";
              e.pwd = "developer";
              try{
              c =     e.getAllocations(tradeID, broker_cd, product_id, contact_group_id, security_type_id);
              catch(SQLException se){
                   se.printStackTrace();

    Silly me! had switched the parameters to the method in Java.

  • Need Help in writing a UDF

    Hi,
    Please help in writing a UDF for these fields in mapping, which I need for the object Iu2019m doing currently.
    The fields are like this:
    1)         batch_no = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/5000)+1",
    2)         lot_id = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/500)+1",
    3)        How to use JDBC connection factory class in the UDF.
    Some logic I can provide which I know i.e. Power (2, 28) means 2 to the power of 28 (2 multiplied 28 times), Trunc means truncate, X_TXN_SAP_Parts is a database table.The Target fields are Batch_no, lot_id & Objid.Actually, objid is mapped initially to a source field i.e. Object ID and in this function it is only being used for the calculation of the batch_no.
    Thanks in Advance,
    Sreedhar.

    Hi,
    Following with my query I've tried to use this code but still I'm unable to execute the mapping.
    import java.util.*;
    import com.sap.aii.mapping.lookup.*;
    import com.sap.aii.mapping.lookup.*;
    DataBaseAccessor accessor = null;
    DataBaseResult JDBCOutPayload = null;
    String BusinessSystem="clarify_dev_bizsys";
    //give your business system having channel name
    String CommunicationChannel="JDBC_TO_CDEV";
    //give your channel name
    String InputPayload= " select X_TXN_PRE_SITE_XFACE.nextval from dual;";
    //give your sql query
    try {
    Channel channel =
    LookupService.getChannel(BusinessSystem,CommunicationChannel);
    accessor = LookupService.getDataBaseAccessor(channel);     
    DataBaseResult resultSet = accessor.execute(InputPayload);
         for(Iterator rows = resultSet.getRows();rows.hasNext();){  
         Map rowMap = (Map)rows.next();
         Object cValue = rowMap.get("batchno");
    //field name of field required , as in database
          catch (Exception e) {}
          finally {
                  if (accessor != null)
                  accessor.close();
           result.addValue((String)cValue);
    --> I don't know what are the parameters to be used and how to be used in the UDF because this is the first time I'm writing a UDF.
    --> The problem in using this query is that both OBJID & BatchNo. are on the target side and the value for the OBJID is retrieved by a SELECT query from the database.
    Kindly help me how to resolve this query of mine.
    Thanks in Advance.
    Sreedhar.

  • Function sequence error

    Hi Chris, we where using this Java code with TimesTen 5.1.34:
    while (rs.next()) {
    associatedMsbs.add(Integer.toString(rs.getInt(HGROUPID)));
    // Prepare object to insert in database
    SvcLog_VO svcLog = new SvcLog_VO();
    svcLog.setLogId(svcLogDAO.getlogIdNextVal(conn));
    svcLog.setService( CommonConstants.MobileSwitchboardSvcId );
    svcLog.setOperType( CommonConstants.OPER_TYPE_UPDREL );
    svcLog.setEntityType( CommonConstants.ENTITY_TYPE_MOBILESWITCHBOARD);
    svcLog.setEntityId( rs.getInt(HGROUPID) );
    svcLog.setRelEntityId( woUserId );
    // Insert object in database
    svcLogDAO.insertData(svcLog, conn);
    This code no longer works in TimesTen 7.0.3. We receive the following error:
    [TimesTen 7.0.3.0.0 ODBC Driver]Function sequence error.
    We had to change the code this way:
    while (rs.next()) {
    // Prepare object to insert in database
    SvcLog_VO svcLog = new SvcLog_VO();
    svcLog.setLogId(svcLogDAO.getlogIdNextVal(conn));
    svcLog.setService( CommonConstants.MobileSwitchboardSvcId );
    svcLog.setOperType( CommonConstants.OPER_TYPE_UPDREL );
    svcLog.setEntityType( CommonConstants.ENTITY_TYPE_MOBILESWITCHBOARD);
    svcLog.setEntityId( rs.getInt(HGROUPID) );
    svcLog.setRelEntityId( woUserId );
    // Store object in ArrayList
    svcLogs.add(svcLog);
    // Insert the objects in the ArrayList in database
    for (int i = 0; i < svcLogs.size(); i++) {
    SvcLog_VO svcLog = (SvcLog_VO)svcLogs.get(i);
    svcLogDAO.insertData(svcLog, conn);
    Once we split the code in two, first iterating the ResultSet and then inserting the objects, it works properly again. Is there any known issue in TimesTen about this?
    Thanks in advance,

    Hi, Chris:
    The code where this occurs is the following:
    public void insertParameters(String xxx1, String xxx2, String xxx3,
    int xxx4, Connection conn) throws TTException, SQLException {
    PreparedStatement ps = null;
    String query = null;
    try {
    query = queryInsert;
    ps = conn.prepareStatement(query);
    ps.setInt(1, xxx1);
    ps.setString(2, xxx2);
    ps.setString(3, xxx3);
    ps.setString(4, xxx4);
    // If debug is activated, the query is printed
    if (log.isDebugEnabled()) {
    ReadableQuery rq = new ReadableQuery();
    rq.addParam(new Integer(xxx1));
    rq.addParam(new String(xxx2));
    rq.addParam(new String(xxx3));
    rq.addParam(new String(xxx4));
    log.debug(" Query to execute .. [" + rq.get(query) + "]");
    ps.executeUpdate();
    // Exception handling
    catch (Exception ex) {
    log.error(ex);
    throw new TTException(ex);
    } // Resources are closed
    finally {
    try {
    if (ps != null) {
    ps.close();
    } catch (SQLException e) {
    log.error("Error closing JDBC resources");
    throw e;
    This method accesses to DDBB and inserts data in a table with the following structure
    Command> desc wo.bs_tb_bsvc_param_values;
    Table XXXXXXX:
    Columns:
    *aaa                          TT_INTEGER NOT NULL
    *bbb                       TT_CHAR (35) NOT NULL
    ccc TT_CHAR (10) NOT NULL
    ddd TT_CHAR (256) NOT NULL
    1 table found.
    (primary key columns are indicated with *)
    Command>
    Thanks.

  • How to format this table in jsp page?

    I have a table in database and there are four data field in it.They are "id","name","email","registetime".
    In javabean,I add all this data to a vector:" ResultSet rs;
    while(rs.next()){
    vec.add(rs.getString("id");
    vec.add(rs.getString("name");
    vec.add(rs.getString("email");
    vec.add(rs.getString("registetime");} ";
    I use a Iterator to read all the data to jsp page:"
                   iter=vec.iterator();
                   while(iter.hasNext()){
                   int i=0;               
                   %>
                   <table border="1" bordercolor="#FF6699" bgcolor="#CCCC99">
                   <%
                   if(i==0|i%8==0){
                   out.println("<td><tr>");
                   %>
                   <%=iter.next()%>
                   </td>
    <%
                   if(i%8==0)
                   out.println("</tr></td>");
                   i++;
                   %></table>
    I use a variable i for change range.I want to output a '\n' after output 4 data.But now the data in IE is this:
    1
    lyo
    [email protected]
    2003-6
    2
    Yashnoo
    [email protected]
    2003-7
    It not that I want to get.I means I want to get data like this:
    1 lyo [email protected] 2003-6
    2 Yashnoo [email protected] 2003-7
    How can I do? :(

    Anyone has idea?But I change it to this:
    <body>
    <table border="1" bordercolor="#FF6699" bgcolor="#CCCC99">
    <%
    Iterator iter=null;
    ResultSet rs=null;
    Vector vec=new Vector();
    vec=lyo.addData(rs,vec);
    iter=vec.iterator();
    try{
    while(iter.hasNext()){
    int i=0;
    %>
    <%
    if(i%8==0){
    out.print("<tr>");
    out.print("<td>");
    %>
    <%=iter.next()%>
    <%
    out.print("</td>");
    if(i%8==0){
    out.print("</tr>");
    i++;
    %></table>
    <%
    }catch(Exception e){
    out.println(e.toString());
    %>
    It can't help? Why?

  • Calling a Stored Procedure From Database Using XI.

    Hi,
    Please help in writing a UDF for these fields in mapping, which I need for the object Iu2019m doing currently.
    The fields are like this:
    1) batch_no = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/5000)+1",
    2) lot_id = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/500)+1",
    3) How to use JDBC connection factory class in the UDF.
    Some logic I can provide which I know i.e. Power (2, 28) means 2 to the power of 28 (2 multiplied 28 times), Trunc means truncate, X_TXN_SAP_Parts is a database table.The Target fields are Batch_no, lot_id & Objid.Actually, objid is mapped initially to a source field i.e. Object ID and in this function it is only being used for the calculation of the batch_no.
    I've tried to use this code but still I'm unable to execute the mapping.
    import java.util.*;
    import com.sap.aii.mapping.lookup.*;
    import com.sap.aii.mapping.lookup.*;
    DataBaseAccessor accessor = null;
    DataBaseResult JDBCOutPayload = null;
    String BusinessSystem="clarify_dev_bizsys";
    //give your business system having channel name
    String CommunicationChannel="JDBC_TO_CDEV";
    //give your channel name
    String InputPayload= " select X_TXN_PRE_SITE_XFACE.nextval from dual;";
    //give your sql query
    try {
    Channel channel =
    LookupService.getChannel(BusinessSystem,CommunicationChannel);
    accessor = LookupService.getDataBaseAccessor(channel);
    DataBaseResult resultSet = accessor.execute(InputPayload);
    for(Iterator rows = resultSet.getRows();rows.hasNext();){
    Map rowMap = (Map)rows.next();
    Object cValue = rowMap.get("batchno");
    //field name of field required , as in database
    catch (Exception e) {}
    finally {
    if (accessor != null)
    accessor.close();
    result.addValue((String)cValue);
    --> I don't know what are the parameters to be used and how to be used in the UDF because this is the first time I'm writing a UDF.
    --> The problem in using this query is that both OBJID & BatchNo. are on the target side and the value for the OBJID is retrieved by a SELECT query from the database.
    Kindly help me how to resolve this query of mine.
    Thanks in Advance.
    Sreedhar.

    Hi,
    The scenario is like I've to get a field (OBJID) value after using a SELECT statement from the database and use the same value for calculating another field values which is BATCHNO & LOTID.
    OBJID, BATCHNO and LOTID are from the same database.
    Thats all I was provided as the input.
    Do let me know if you need anymore information. I'll try to give as much input to the extent I know.
    Sreedhar.

  • Calling a Stored Procedure with Parameter using an UDF

    Hi All,
      I have a requirement where I need to use database lookup. In that I am calling the Stored Procedure using UDF. For example sp_flow ., for this I have to pass<INTID> and <USDERID> to get the response.
    I am using the below code to excute this.
    Channel channel = null;                                                   
    Map rowMap = null;                                                        
    DataBaseAccessor accessor = null;                                         
    DataBaseResult resultSet = null;                                          
    String Query = null;   
    //Query ="EXECUTE dbo.sp_flow <INTID> <USERID>;                                                 
    Query = "EXECUTE dbo.sp_flow  \'304\' ,  \'shankar\'  " ;       
      try{                                                                               
    //Determine a channel, as created in the Configuration                    
    channel =                                                                 
    LookupService.getChanne"BS_XXX","CC_XXX_JDBC_Rcv");                                                                               
    //Get a system accessor for the channel. As the call is being made to an  
    DB, an DatabaseAccessor is obtained.                                      
    accessor = LookupService.getDataBaseAccessor(channel);                                                                               
    //Execute Query and get the values in resultset                           
    resultSet = accessor.execute(Query);                                                                               
    for(Iterator rows = resultSet.getRows();rows.hasNext();){                 
    rowMap = (Map)rows.next();                                                                               
    result.addValue((String)rowMap.get("FLOW_ID"));                       
    I am getting the error "Error when calling an adapter by using the communication channel CC_NWLS_TLA_JDBC_Rcv (Party: , Service: BS_MICROSOFT_SQLWLS20DEV_D, Object ID: d30aace599de3cd69548bf145d0724b7) XI AF API call failed. Module exception: (No information available). Cause Exception: 'Error processing request in sax parser: Error when executing statement for table/stored proc. 'table' (structure 'statement'): com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set."
    let me know how do this.
    Regards
    shankar
    Edited by: Shankar on Jun 9, 2009 2:51 PM
    Edited by: Shankar on Jun 9, 2009 3:02 PM

    first of all calling a SP via the lookup API, there is a workaround but it is not at all recommended
    FYI
    /people/arpil.gupta/blog/2008/11/03/workaround-for-jdbc-scenarios - DB Lookup via Stored procedure
    http://help.sap.com/javadocs/NW04S/current/pi/com/sap/aii/mapping/lookup/DataBaseAccessor.html
    The accessor does not support transactional behaviour. Therefore, the method should not be used to execute insert or update statements on the database which can lead to inconsistencies. The accessor should only be used to read data from a database table.

  • Missing Time value in Date

    Hi Pros,
    I have a table in my oracle database, lets say TableA having a cloumn, say ColumnA with data type as DATE.
    Now, inside my JDBC code, I fire a query which returns number of coulmns in a ResultSet (Including the one having DATE datatype).
    When I fetch the value of 'ColumnA' column while iterating the resultset, I get a value of type java.sql.Date.
    Now on UI side I need to display date and time value from this coulmn in a format dd-mm-yy hh:mm:ss, I used SimpleDateFormat to do that
    but the Date on UI shows a date and time value with time value set to 00:00:00 for every row which has been fetch by the query.
    SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy  HH:mm:ss");
    String dateAndTimeAsString  = formatter.format(resultSet.getDate("CREATION_DATETIME"))The thing is can see the proper time values in database table, but it seems it is being skipped somhow.
    I also tried convetring java.sal.Date to java.uitl.Date using following code format , but still the same results........
    java.util.Date    utilDate = new java.util.Date((resultSet.getDate("CREATION_DATETIME")).getTime();then converted this Date into string using SimpleDateFormt.format() method, but still did not hit the spot :(
    String dateAndTimeAsString = formatter.format(utilDate);Any idea ? how can i achive this .................
    Thanks in advance..........

    marathaWarrior wrote:
    You are right, I should have tried it before replying,
    But the thing is for a single line of change in code , it takes nearly an hour to re-build the project (and there is no short cut as code builds so many dependent jars). Hope you can understand. Any way I will give it a try.I glad you got it working.
    You don't necessarily have to re-build your entire application to try something.
    The next time you are in a similar situation try making a little test app that just does what you want to test.

  • Error in User defined function for jdbc lookup

    I am getting th error as follows "Method TestJDBCAPI$ with 2 arguments not found in class com.sap.xi.tf._JLU_MM_" when i a m testing in message mapping

    //write your code here
    String Query = " ";
    Channel channel = null;
    DataBaseAccessor accessor = null;
    DataBaseResult resultSet = null;
    //Build the Query String
    Query = "Select role from login where username = " + username[0] + " and password = " + password[0] ;
    try{
    //Determine a channel as created in the configuration
    channel = LookupService.getChannel("JLU_BUSS","JLU_chan");
    //  Get a system accessor for a channel.As the call is being made to the database an database accessor is obtained.
    accessor = LookupService.getDataBaseAccessor(channel);
    // Execute the Query and get the values in the resultSet.
    resultSet = accessor.execute(Query);
    for(Iterator rows = resultSet.getRows();rows.hasNext();)
    Map rowMap = (Map)rows.next();
    result.addValue((String)rowMap.get("role"));
    catch(Exception ex){
    result.addValue(ex.getMessage());
    Above is my udf.My logic is that for the given username and password it should select the corresponding role from the database.

  • JDBC look Up query taking more time to process

    Hi all,
      I am using JDBC Look Up in my project to retreive data from multiple tables.But the problem here is it is taking 10-12 minutes for processing the query which has around 770 records.So my question is there any way that i can reduce the time of processing query.
    Ex:Select EmpId from EmpTable where EmpId>500 and EmpName="Arun"
    Here I have 770 records and it is taking 12 minutes to retreive results.
    Is there any database tuning technique that we can use in JDBC Look up in PI?
    Thanks in Advance.
    Regards,
    Yeshwanth

    >   I am using JDBC Look Up in my project to retrieve data from multiple tables.But the problem here is it is taking 10-12 minutes for processing the query which has around 770 records.So my question is there any way that i can reduce the time of processing query.
    This is happening since you are executing the Query (Select F1 from tablename where segment1='X', segment2='Y',segment3='X1',segment4='Y1',segment5='X2',segment6='Y2') for each record. So, the execution is 770 times in your case, which means it is opening and closing DB Accessor channel 770 times which is basically causing performance.
    Better pass all fields in one Context as input to JDBCLookUP UDF and logically iterate by opening only one DB accessor.
    I am just providing a rough UDF code, so it might not work at first shot. Change it according to your requirement.
    Note: UDF should be advanced in nature (context or Queue)
    Sample Code
    Channel channel = null;
    Map rowMap = null;
    DataBaseAccessor accessor = null;
    DataBaseResult resultSet = null;
    try
              //Determine a channel, as created in the Configuration
              channel = LookupService.getChannel("<BUSINESSYSTEM>","<CHANNELNAME>");// give your service and channel
              //Get a system accessor for the channel. As the call is being made to an DB, an DatabaseAccessor is obtained.
              accessor = LookupService.getDataBaseAccessor(channel);     
    catch (Exception e1)
         e1.printStackTrace();
    for (i=0; i<a.length;i++ )
         //Query = "Select F1 from tablename where segment1='X', segment2='Y',segment3='X1',segment4='Y1',segment5='X2',segment6='Y2'";
         Query = "Select " + a<i> + " from tablename where segment1='X', segment2='Y',segment3='X1',segment4='Y1',segment5='X2',segment6='Y2'";
         try{
                   resultSet = null;
                   //Execute Query and get the values in resultset
                   resultSet = accessor.execute(Query);
                   for(Iterator rows = resultSet.getRows();rows.hasNext();)
                        rowMap = (Map)rows.next();
                        result.addValue((String)rowMap.get(a<i>)); //this statement might not be correct as your query is already fetching F1, so make some adjust in this statement accordingly
              catch(Exception e2)
                   //result.addValue(ex.getMessage());
                   e2.printStackTrace();
    try{
              if (accessor!=null)
                   accessor.close();
         catch(Exception e3)
              e3.printStackTrace();
    Let us know the outcome.......
    Regards,
    Praveen Gujjeti.
    Edited by: Praveen Gujjeti on Jun 29, 2010 10:38 PM

  • Error while testing in message mapping for JDBC lookup

    The error is as follows.
    Exception during processing the payload.Problem when calling an adapter by using communication channel JLU_chan (Party: , Service: JLU_BUSS, Object ID: 0519f96e59c534829ebdcdea837dacb7) XI AF API call failed. Module exception: (No information available). Cause Exception: 'Error processing request in sax parser: Error when executing statement for table/stored proc. 'table' (structure 'statement'): java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Missing ), ], or Item in query expression 'username  = [Ljava.lang.String;@d7f610 and password = [Ljava.lang.String;@5b96eb'.'.
    com.sap.aii.mapping.lookup.LookupException: Problem when calling an adapter by using communication channel JLU_chan (Party: , Service: JLU_BUSS, Object ID: 0519f96e59c534829ebdcdea837dacb7) XI AF API call failed. Module exception: (No information available). Cause Exception: 'Error processing request in sax parser: Error when executing statement for table/stored proc. 'table' (structure 'statement'): java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Missing ), ], or Item in query expression 'username  = [Ljava.lang.String;@d7f610 and password = [Ljava.lang.String;@5b96eb'.'.
         at com.sap.aii.ibrun.server.lookup.AdapterProxyLocal.execute(AdapterProxyLocal.java:131)
         at com.sap.aii.ibrun.server.lookup.SystemAccessorInternal.execute(SystemAccessorInternal.java:68)
         at com.sap.aii.ibrun.server.lookup.SystemAccessorHmiServer.process(SystemAccessorHmiServer.java:149)
         at com.sap.aii.ibrun.server.lookup.SystemAccessorHmiServer.process(SystemAccessorHmiServer.java:77)
         at com.sap.aii.utilxi.hmis.server.HmisServiceImpl.invokeMethod(HmisServiceImpl.java:169)
         at com.sap.aii.utilxi.hmis.server.HmisServer.process(HmisServer.java:178)
         at com.sap.aii.utilxi.hmis.web.HmisServletImpl.processRequestByHmiServer(HmisServletImpl.java:296)
         at com.sap.aii.utilxi.hmis.web.HmisServletImpl.processRequestByHmiServer(HmisServletImpl.java:211)
         at com.sap.aii.utilxi.hmis.web.workers.HmisInternalClient.doWork(HmisInternalClient.java:70)
         at com.sap.aii.utilxi.hmis.web.HmisServletImpl.doWork(HmisServletImpl.java:496)
         at com.sap.aii.utilxi.hmis.web.HmisServletImpl.doPost(HmisServletImpl.java:634)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:160)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Root Cause:
    com.sap.aii.af.service.api.AFException: XI AF API call failed. Module exception: (No information available). Cause Exception: 'Error processing request in sax parser: Error when executing statement for table/stored proc. 'table' (structure 'statement'): java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Missing ), ], or Item in query expression 'username  = [Ljava.lang.String;@d7f610 and password = [Ljava.lang.String;@5b96eb'.'.
         at com.sap.aii.af.service.api.AdapterAccess.sendMsg(AdapterAccess.java:214)
         at com.sap.aii.af.service.api.AdapterAccess.execute(AdapterAccess.java:283)
         at com.sap.aii.ibrun.server.lookup.AdapterProxyLocal.execute(AdapterProxyLocal.java:123)
         at com.sap.aii.ibrun.server.lookup.SystemAccessorInternal.execute(SystemAccessorInternal.java:68)
         at com.sap.aii.ibrun.server.lookup.SystemAccessorHmiServer.process(SystemAccessorHmiServer.java:149)
         at com.sap.aii.ibrun.server.lookup.SystemAccessorHmiServer.process(SystemAccessorHmiServer.java:77)
         at com.sap.aii.utilxi.hmis.server.HmisServiceImpl.invokeMethod(HmisServiceImpl.java:169)
         at com.sap.aii.utilxi.hmis.server.HmisServer.process(HmisServer.java:178)
         at com.sap.aii.utilxi.hmis.web.HmisServletImpl.processRequestByHmiServer(HmisServletImpl.java:296)
         at com.sap.aii.utilxi.hmis.web.HmisServletImpl.processRequestByHmiServer(HmisServletImpl.java:211)
         at com.sap.aii.utilxi.hmis.web.workers.HmisInternalClient.doWork(HmisInternalClient.java:70)
         at com.sap.aii.utilxi.hmis.web.HmisServletImpl.doWork(HmisServletImpl.java:496)
         at com.sap.aii.utilxi.hmis.web.HmisServletImpl.doPost(HmisServletImpl.java:634)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:160)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

    I'll give you the query.Can you please check my code.Code is as follows.
    //write your code here
    String Query = " ";
    Channel channel = null;
    DataBaseAccessor accessor = null;
    DataBaseResult resultSet = null;
    //Build the Query String
    Query = "Select role from login where username  = " + username + " and password = " + password + "" ;
    try{
    //Determine a channel as created in the configuration
    channel = LookupService.getChannel("JLU_BUSS","JLU_chan");
    //  Get a system accessor for a channel.As the call is being made to the database an database accessor is obtained.
    accessor = LookupService.getDataBaseAccessor(channel);
    // Execute the Query and get the values in the resultSet.
    resultSet = accessor.execute(Query);
    for(Iterator rows = resultSet.getRows();rows.hasNext();)
    Map rowMap = (Map)rows.next();
    result.addValue((String)rowMap.get("role"));
    catch(Exception ex){
    result.addValue(ex.getMessage());
    finally{
    try{
    if (accessor!=null) accessor.close();
    catch(Exception e){
    result.addValue(e.getMessage());

  • BPM with 2 JDBC outbound interfaces and one inbound file interface

    Hi,
    I have a scenario where data is coming from  different databases into XI and after processing the data it creates a file at the target side. Some calculations are to be done in the middleware and the result will be sent through a file.
    My question is
    1. BPM will be used in this scenario?
    2. There will 2 outbound interfaces(one for each database access), 2 abstract interfaces and one inbound interface(file). Please correct me if I am wrong.
    3. I have to multiply the value of field from one database to a particular value in another database and get the final result. For e.g exchange rate from one database is multiplied to Transaction currency in another database and get the group currency value in the output. Can anyone give the sequence of steps in the intergration process for this scenario as I am new to BPM.
    Thanks,
    Aparna

    Thanks a lot Liang and madhusudana for your responses.
    Since I can use JDBC lookup for this in my nornal scenario I think no need for BPM.
    I have created the advanced UDF for JDBC lookup code. Below is the code.
    String Query = " ";
    Channel channel = null;
    DataBaseAccessor accessor = null;
    DataBaseResult resultSet = null;
    MappingTrace importanttrace;
    importanttrace = container.getTrace();
    // Build the Query String
    Query = "Select home_cur_code FROM  gltrxcp WHERE company_code = '" + a[0] + "' ";
    try{
    //Determine a channel, as created in the Configuration
    channel = LookupService.getChannel("BS_JDBC_send","cc_JDBClookup_rec");
    //Get a system accessor for the channel. As the call is being made to an DB, an DatabaseAccessor is obtained.
    accessor = LookupService.getDataBaseAccessor(channel);
    //Execute Query and get the values in resultset
    resultSet = accessor.execute(Query);
    importanttrace.addWarning("resultset" + resultSet );
    for(Iterator rows = resultSet.getRows();rows.hasNext();){
    Map rowMap = (Map)rows.next();
    result.addValue((String)rowMap.get("HOME_CUR_CODE"));
    importanttrace.addWarning("result" + result );
    catch(Exception ex){
    result.addValue(ex.getMessage());
    finally{
    try{
    if (accessor!=null) accessor.close();
    catch(Exception e){
    result.addValue(e.getMessage());
    But I am not getting the desired result. I am getting result as 'Null'.
    Can you please help in resolving this issue. I have also used trace for find out where it is passing Null and found that 'result' is coming null. Do i also need to parse it before passing it to 'result'?
    Can anyone send sample code for JDBC lookup.

  • Have some doubt regarding the  weblog (Lookup's in XI made simpler)

    Hi All,
    I have created the same scenario as mentioned in Siva's weblog (Lookup's in XI made simpler).
    I having some doubts regarding the scenario, it will be great if you help me to resolve the same.
    I am having a file-file scenario where I need to do lookup in database(MS-Access)  through mapping.
    The standard file-file scenario is in place and in addition I have created a receiver jdbc channel . I  have also created the receiver agreement for the same in the cofiguration.
    While creating the receiver agreement you have to specify the interface name which includes the message type…I have specified the normal format which we specify while configuring the jdbc receiver adapter.
    In the message mapping I have created a advance user defined function as mentioned in your weblog which calls my receiver jdbc channel.
    I have also specified the select query to be executed in the mapping program.
    While testing I am getting the following error
    Cannot produce target element /ns0:Role_MT/URole. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd
    <b>Can you please suggest me what all I need to do in addition to the file-file scenario for this lookup scenario to work.</b>
    Thanks and Regards
    Rahul

    Hi,
    Following is my user defined function
    //write your code here
    String Query = "";
    Channel channel = null;
    DataBaseAccessor accessor = null;
    DataBaseResult resultSet = null;
    Query = "Select URole from  Lookup where UName = '  " + UName[0] + "  ' and UPassword = '  " + Pwd[0] +" '  ";
    try{
    channel = LookupService.getChannel("DB_service","JDBC_channel_receiver");
    accessor = LookupService.getDataBaseAccessor(channel);
    resultSet  = accessor.execute(Query);
    for(Iterator rows = resultSet.getRows();rows.hasNext();){
    Map rowMap = (Map)rows.next();
    result.addValue((String)rowMap.get("URole"));
    catch(Exception ex){
    result.addValue(ex.getMessage());
    finally{
    try{
    if (accessor!= null) accessor.close();
    catch(Exception ex){
    result.addValue(ex.getMessage());
    Thanks and Regards
    Rahul

  • DB Lookup Not Initialising PLz Help!

    Dear all,
    I Tried to do DB Lookup as told in this blog by siva
    /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
    I used the below code.
    I am not Getting any error, the mapping is successfully ACTIVATED. But in the Receiver field i am Getting Null as output , the DB lookup which i have mentioned is not connecting to the Database and executing and fetching the query. Just in the receiver field its througing the Null valuse(Default Initialisation Values). The Required Value is not fetched by using the communication channel.
    I am getting the above error when i try to TEST THE MAPPING in IR.
    Below is the code i used.
    SERVER:XI 3.0
    SP:18
    RECEIVER DATABSE: MSQL SERVER 2000
    CODE----
    *//write your code here
    String Query = "";
    Channel channel = null;
    DataBaseAccessor accessor = null;
    DataBaseResult resultSet = null;
    Query = "Select cir_id from circle where cir_sap = 'IDBL'";
    try{
    channel = LookupService.getChannel("<Business Service/System Name>","JDBC_channel_receiver Communication channel");
    accessor = LookupService.getDataBaseAccessor(channel);
    resultSet = accessor.execute(Query);
    for(Iterator rows = resultSet.getRows();rows.hasNext();){
    Map rowMap = (Map)rows.next();
    result.addValue((String)rowMap.get("cir_id"));
    catch(Exception ex){
    result.addValue(ex.getMessage());
    finally{
    try{
    if (accessor!= null) accessor.close();
    catch(Exception ex){
    result.addValue(ex.getMessage());
    END CODE----
    Please help me out.
    I am getting output as null. But in database value is there for cir_id where cir_sap='IDBL'.
    Regards,
    Prakash
    Edited by: senthilprakash selvaraj on Jul 2, 2008 2:37 AM

    Dear Varun,
    Thanks a Million Times.actually to openly say. U R ANSWER only HELPED And My querry worked.
    But Varun by mistake i gave the total points the other person, i thought that it was u.! in a hurry i gave the points to the other person yaar ! Please dont mistake me. and i am not in a position to revert it .
    Please dont mistake me both of you. And thans a ZILLION times for all who tried to help me really it means something for me.
    Regards,
    Prakash

Maybe you are looking for

  • Upgrading my iMac G5 (10.3.9) to 10.5.4

    I recently purchased a new MacBook Intel-based computer that came loaded with Mac OS X 10.5.4. It also came with the discs required to reload 10.5.4 in case my computer ever crashes. My question is: can I take those discs and upgrade my old iMac G5 w

  • Seeing XML payload being sent from PI

    Hi,     I have received a payload from my SAP system and can see this in SXMB_MONI. I cannot see the xml payload that results after mapping and is then sent from PI to a web service. I have looked everywhere i can think of but to no avail. Can anyone

  • Could not connect to a Oracle DataBase

    I am using WTP 2.0 and want to connect to the Oralce Database and use it as "SQL Developer" kind in eclipse. I updated the entire datatools project and when i tried to connect to the Oracle DB, it would not connect. I also tried to refer to the http:

  • Can't run java .class programs from Windows command line!

    I have tried to get a program that I wrote with the JDK to run from the Windows command line, but it is not working. I typed: java HelloWorld Where my .class was HelloWorld.class, a compiled java program. I spelled the name correctly (and I am in the

  • Merge / Import data from one XLSX to corresponding XLSX tab

    After using Excel for decades I've once more encountered a request I cannot answer. We have an Excel 2010 workbook with 40+ uniquely named tabs. We have a second workbook with the names and addresses of our customers. We would like to import the addr