Skip to Content
author's profile photo Former Member
Former Member

see this error

/*

  • To change this template, choose Tools | Templates

  • and open the template in the editor.

*/

package hello;

/**

*

  • @author MFTD1039

*/

import java.io.ByteArrayInputStream;

import java.io.IOException;

import java.io.InputStreamReader;

import org.kxml.Xml;

import org.kxml.kdom.Document;

import org.kxml.kdom.Element;

import org.kxml.parser.ParseEvent;

import org.kxml.parser.XmlParser;

/**

*

  • @author mobilejava026

*/

public class XmlUtilities {

static XmlParser parser;

public static int dnldCnt = 0;

static String dnldStr="";

static VDto[] obj;

static VDto Vo=null;

public static String encode(String str){

System.out.println("*********encode******");

if(str == null)

return str;

return Xml.encode(str);

}

public static Object parseNstore(String strData){

encode(strData);

Document doc = new Document();

if(strData == null)

return "No Data";

try{

// System.out.println("****************************** Master Data parseNstore started "+strData);

ByteArrayInputStream bin=new ByteArrayInputStream(strData.getBytes());

InputStreamReader is = new InputStreamReader(bin);

parser = new XmlParser(is);

doc.parse(parser);

parser = null;

}catch (IOException ioe) {

System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Master Data Exception"+ioe);

System.err.println(ioe);

ioe.printStackTrace();

parser = null;

doc = null;

return ""+ioe;

}

try{

// Opportunities[] objArrOpportunities = null;

// Activities[] objArrActivities = null;

// Contacts[] objArrContacts = null;

// Accounts[] objArrAccounts = null;

String strOpCode = null;

int item_count = 0;

Element root = doc.getRootElement();

int child_count = root.getChildCount();

if(child_count == 0){

/* if(fetch){

Fetch f = new Fetch();

f.setStrErrorMsg("No data from server");

return f;

}*/

return "No Data from Server";

}

for (int i = 0; i < child_count ; i++ ) {

if (root.getType(i) != Xml.ELEMENT) {

continue;

}

Element element = root.getElement(i);

String value = element.getAttribute("name").getValue();

// String rows = element.getAttribute("NoOfRows").getValue();

System.out.println("---- satish 80-->"+value);

if(value.equalsIgnoreCase("SelectionOne")){

// dnldCnt = dnldCnt+Integer.parseInt(rows);

Element item = null;

item_count = element.getChildCount();

System.out.println("child count 87:"+item_count);

for(int j = 0; j<item_count; j++){

if (element.getType(j) != Xml.ELEMENT){

System.out.println("coming in continue :");

continue;

}

//System.out.println("element 93:"+element.getElement(j));

item = (Element)element.getElement(j);

// System.out.println("first child :"+item.getChild(0));

System.out.println("CHILD COUNT 96:"+item.getChildCount());

obj=new VDto[item.getChildCount()];

Element ele1=null;

for(int cnt=0;cnt<item.getChildCount();cnt++){

if (item.getType(cnt) != Xml.ELEMENT){

System.out.println("coming in continue :");

continue;

}

// System.out.println("element 103:"+item.getElement(cnt));

ele1=item.getElement(cnt);

//System.out.println("Namme "ele1.getName()" value :"+ele1.getText(cnt));

Vo=new VDto();

if(ele1.getName().equals("empname")){

// System.out.println("Employee name :"+ele1.getText());

Vo.setName(ele1.getText());

}

if(ele1.getName().equals("no")){

// System.out.println("Employee NO :"+ele1.getText());

Vo.setNumber(ele1.getText());

}

obj[cnt]=Vo;

}

}

}else if(value.equalsIgnoreCase("Employee")){

// another table like above

}

}// end for

}

catch(Exception e){

e.printStackTrace();

}

return obj;

}

}

-


package com.his.billing.dao;

import java.sql.Connection;

import java.sql.ResultSet;

import java.sql.Statement;

import java.util.ArrayList;

import com.his.billing.DTO.ReprintInvoicesDTO;

import com.his.common.utilities.ConnectionBroker;

import com.his.common.utilities.DatabaseTypeInterface;

public class FirstDAO {

public String getInvoice()

{

Connection connection = null;

Statement statement = null;

ResultSet rs = null;

ReprintInvoicesDTO riDTO = null;

int count = 0;

StringBuffer strbuf= new StringBuffer();

strbuf.append("select *\n" +

" from (select s.mchr_chargeid_id, substr(s.mchr_chargename_nm,0,15) \n" +

" from his_mastercharges_hdr s)\n" +

" where rownum <= 15");

StringBuffer st=new StringBuffer();

/* strbuf.append("select *\n" +

" from (select h.mser_servicescode_cd, h.mser_servicesname_nm\n" +

" from his_masterservices_hdr h)\n" +

" where rownum <= 30");*/

ArrayList alDAO;

StringBuffer sb= new StringBuffer();

try

{

ConnectionBroker con = new ConnectionBroker();

connection = con.getConnectionSecond();

statement = connection.createStatement();

System.out.println("Select Query=30==>\n"+strbuf.toString() );

rs = statement.executeQuery(strbuf.toString());

alDAO = new ArrayList();

sb.append("<Root>");

sb.append("<Table name='SelectionOne'>");

sb.append("<selection>");

while(rs.next())

{

sb.append("<empname>" rs.getString(2)"</empname>");

sb.append("<no>"rs.getString(1)"</no>");

}

sb.append("</selection>");

sb.append("</Table>");

sb.append("</Root>");

}

catch(Exception e)

{

e.printStackTrace();

}

finally

{

try{

if(rs!=null)

{

rs.close();

}

}

catch(Exception e){}

try

{

if(statement!=null)

{

statement.close();

}

}

catch(Exception e){}

try

{

if(connection!=null)

{

connection.close();

}

}

catch(Exception e){}

}

return sb.toString();

}

}

-


Exception

pname>PARATH ORMONE(P</empname><no>459</no><empname>UREA+ELECTROLYT</empname><no>460</no></selection></Table></Root>?; @1:4554

at org.kxml.parser.XmlParser.resolveCharacterEntity(+33)

at org.kxml.parser.XmlParser.readText(+259)

at org.kxml.parser.XmlParser.peek(+190)

at org.kxml.kdom.Node.parse(+6)

at org.kxml.kdom.Element.parse(+45)

at org.kxml.kdom.Node.parse(+80)

at org.kxml.kdom.Element.parse(+45)

at org.kxml.kdom.Node.parse(+80)

at org.kxml.kdom.Element.parse(+45)

at org.kxml.kdom.Node.parse(+80)

at org.kxml.kdom.Element.parse(+45)

at org.kxml.kdom.Node.parse(+80)

at org.kxml.kdom.Document.parse(+5)

at hello.XmlUtilities.parseNstore(XmlUtilities.java:50)

at hello.ByteEx$ThredEx.run(ByteEx.java:454)

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2009 at 10:18 AM

    sb.append("<Root>");

    sb.append("<Table name='SelectionOne'>");

    sb.append("<selection>");

    while(rs.next())

    {

    sb.append("<empname>" rs.getString(2)"</empname>");

    sb.append("<no>"rs.getString(1)"</no>");

    }

    sb.append("</selection>");

    sb.append("</Table>");

    sb.append("</Root>");

    Retplace this with

    ==================

    sb.append("<Root>");

    sb.append("<Table name='SelectionOne'>");

    while(rs.next())

    {

    sb.append("<selection empname='");

    sb.append(rs.getString(2)+"u2019 no=u2019");

    sb.append(rs.getString(1)+u201Du2019/>u201D);

    }

    sb.append("</Table>");

    sb.append("</Root>");

    I mean xml like this:

    <Root>

    <Table Name=u201DSelectionu201D>

    <Selection name=u201DSatishu201D id=u201D100u201D/>

    <Selection name=u201DSureshu201D id=u201D101u201D/>

    <Selection name=u201DBooshanamu201D id=u201D102u201D/>

    </Table>

    <Tablell Name=u201DEmployeeu201D>

    <Employee SName=u201Dsiru201D LName=u201Dlastu201D/>

    <Employee SName=u201Dsir1u201D LName=u201Dlast1u201D/>

    </Table>

    </Root>

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      public class HelloMidlet extends MIDlet implements CommandListener,ItemStateListener ,ItemCommandListener{ // implement ItemStatelListener and ItemCommandListener

      and implement method

      public void itemStateChanged(Item item) {

      choiceGroup1 = new ChoiceGroup("choiceGroup1", Choice.EXCLUSIVE, new String[0], new Image[0]);

      choiceGroup1.addCommand(get_itemCommand1());

      choiceGroup1.setItemCommandListener(this);

      get_helloForm().append(cg);

      }

      public void commandAction(Command command, Item item) { // in commandAction listener interface method

      if(item == checkboxObject){

      if(command == okCommand){

      boolean boo[] = new boolean[intialize with checkboxgroup size ];

      // true unnna array location tho checkbox group ki bind chesina array lo nunchi data theesukuni next form lo bind cheyi

      // go to next form

      }

      }

      }

      form.setItemStateListener(this);

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.