• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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




 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic