Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Leonidas Savvides
Ranch Hand
Posts: 403
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13047
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 403
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
input file is too short, no this the problem, and the arrays instatiated, how to initialized if I do not know length?
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic