| Author |
I tried debug failing: trying to incle xml file contents to db table
|
Leonidas Savvides
Ranch Hand
Joined: Jan 31, 2010
Posts: 397
|
|
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: 16487
|
|
|
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: 12327
|
|
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
|
Java Resources at www.wbrogden.com
|
 |
Leonidas Savvides
Ranch Hand
Joined: Jan 31, 2010
Posts: 397
|
|
|
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: 16487
|
|
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.
|
 |
 |
|
|
subject: I tried debug failing: trying to incle xml file contents to db table
|
|
|