webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Error in Inserting Records Into Tamino

  • 1.  Error in Inserting Records Into Tamino

    Posted Tue July 23, 2002 10:10 AM

    I am using servlet API to insert records into Tamino. The problem lies when I try to insert the sixth record, my id (that is the primary key for the record) did not increment as per normal. It increments until the record no.5 only. After this record, the id will remain the same. Below is the sample of codes which does the inserting into Tamino:

    public void doGet (HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {

    try{
    TaminoClient tamino=new TaminoClient(“http://192.0.0.204/tamino/cyansys/studentportal”);

    tamino.startSession();

    response.setContentType(“text/html”);
    PrintWriter out = response.getWriter();

    name = request.getParameter(“prospName”);

    /* This part of code is to process the prospect ID /
    TaminoResult prospTr = tamino.query(“Prospect”);
    Document prospDoc = prospTr.getDocument();
    Element prosp = prospDoc.getDocumentElement();

    NodeList nl_prosp = prosp.getElementsByTagName(“ProspectID”);
    int num_prosp = nl_prosp.getLength();

    Calendar rightNow = Calendar.getInstance();
    int year = rightNow.get(Calendar.YEAR);
    String getYr = Integer.toString(year);

    String yr = getYr.substring(2,4);

    int id = num_prosp + 1110;
    prospectID = “A” + yr + id;

    /
    This part of code is to process the date of birth /
    dob = day + “-” + mth + “-” + year;

    /
    This part of code is to insert the new prospect into Tamino */

    BasicDocument doc=new BasicDocument();

    BasicElement prospect = new BasicElement(doc,“Prospect”);
    BasicElement c = new BasicElement(doc,“ProspectID”);
    c.appendChild(new BasicText(doc, prospectID));
    prospect.appendChild(c);

    c = new BasicElement(doc,“Name”);
    c.appendChild(new BasicText(doc,name));
    prospect.appendChild(c);

    TaminoClient.printTree(prospect);
    TaminoResult tr= tamino.insert(prospect);
    tamino.commit(false);

    tamino.endSession();

    HttpSession sess = request.getSession(true);

    RequestDispatcher rd = getServletContext().getRequestDispatcher(“/RegConfirm.jsp”);

    if (rd != null){
    rd.forward(request,response);
    } else {
    System.out.println(“Null error”);
    response.sendRedirect(“/JSP/InsertError.jsp”);
    }
    }

    catch (TaminoError e){
    System.out.println("Tamino Error Text: " + e.errorText );
    System.out.println("Tamino Error Code: " + e.responseCode );
    }
    }


    ==================================================
    The result of the following will be somthing like this:

    Prospect ID: A021111
    Name: Peter

    Prospect ID: A021112
    Name: John

    Prospect ID: A021113
    Name: Mary

    Prospect ID: A021114
    Name: Siti

    Prospect ID: A021115
    Name: David

    the above 5 records run smoothly but when it reaches record no. 6 the id remain the same as the last one…

    Prospect ID: A021115
    Name: Rita

    Prospect ID: A021115
    Name: Kelly

    Prospect ID: A021115
    Name: Aminah

    Prospect ID: A021115
    Name: Michelle

    Prospect ID: A021115
    Name: Jessicca

    Can i know why?? or is it something wrong wif my codes???

    Pls help… :confused:


    #webMethods
    #webMethods-Tamino-XML-Server-APIs
    #API-Management


  • 2.  RE: Error in Inserting Records Into Tamino

    Posted Tue July 23, 2002 11:52 AM

    ooopsss!! sorry… i did the wrong way myself… :slight_smile:

    I should be using the TaminoResult.getTotalCount() to get the total number of elements.

    Sorry for the inconvenience…

    Thanks and regards… :cool:


    #API-Management
    #webMethods-Tamino-XML-Server-APIs
    #webMethods