This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
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
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply 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: 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
    
    2

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
    
    1
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
    
    2

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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: I tried debug failing: trying to incle xml file contents to db table
 
Similar Threads
I tried find the BUG in this SAX PARSER But NO-RESULT:
problems with JAXP
I do not know in which part of SAX Class
problems with JAXP
problems with JAXP