aspose file tools*
The moose likes Java in General and the fly likes I tried debug failing: trying to incle xml file contents to db table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "I tried debug failing: trying to incle xml file contents to db table" Watch "I tried debug failing: trying to incle xml file contents to db table" New topic
Author

I tried debug failing: trying to incle xml file contents to db table

Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
I tried debug failing: trying to incle xml file contents to db table...
xmlPlantToDB.java:170
public void endElement(String namespaceURI,
String sName, String qName) throws SAXException {

if (state == 1) // here error does not go to endDocument( )
searchonHand[j-1]=str;

if (state == 2)
searchname[j-1]=str; // line 170

xmlPlantToDB.java:47
parser.parse(new File(xmlFile), eventHandler); // line 47




Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18675
    
    8

You haven't initialized the searchname variable, so it's null. And when you try to use it, you get that exception.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
Note that the following implementation:


Will fail to work as expected in many cases where the input file is longer than one buffer load. Any decent tutorial on SAX processing will explain why.

Bill
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
input file is too short, no this the problem, and the arrays instatiated, how to initialized if I do not know length?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18675
    
    8

If you want an array of things, but you don't know how many things are going to be in the array? Then don't use an array. Use a List. An ArrayList would work just fine.

And your questions don't really seem to be about XML, they are ordinary questions about Java programming. Let's move this thread to a general forum about Java programming.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I tried debug failing: trying to incle xml file contents to db table