• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Storing SAX Parser data into MySql

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a live xml feed which i parsed using SAX Parser, i would like to store that data into MySql, I wanted some information on how i would go about this.
 
Sheriff
Posts: 28365
99
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
There are two steps in that process:

(1) Extract the data from the SAX parser.

(2) Put that data into MySQL.

Which of those two steps are you having trouble with?

(By the way, that's a general procedure you should use when trying to solve a complex-looking problem: split the problem into separate parts and solve each of the parts.)
 
Yasin Kothia
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
at the moment, i have just parsed the XML URL using SAX, the next stage is to put the data i have got into MySQL ,if that involves extracting the data then i need help on that also as i have not done such a thing and then placing that data into Mysql.
 
Paul Clapham
Sheriff
Posts: 28365
99
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
Of course before you do any of that, you first have to figure out what you want to do. It looks like you haven't done that yet, so naturally you don't know how to do it.

So the first question is: What data do you want to extract? And the second question is: What data do you want to have in MySQL?

Have you created the database tables you want to fill? Have you looked at the XML documents to figure out where in them is the data you want to use?
 
Yasin Kothia
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i know what i want to extract, As i have only Sax Parsed the data i want to put into the MySQL Database, so all the data parsed trough the SAX Parser goes into MySQL.

I have created the Tables in MySQL, and also looked at the XML to find out what data i want.

Thanks.
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As it involves XML and SAX parser, moving it to XML forum to start with.
 
Paul Clapham
Sheriff
Posts: 28365
99
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

Yasin Kothia wrote:Thanks.



So your problem is solved, then? Excellent!
 
Yasin Kothia
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry no not solved, I need help putting the data into MySql after using sax to parse it.
 
Paul Clapham
Sheriff
Posts: 28365
99
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You seem to be avoiding specific questions. "I need help putting data into MySQL" is not a specific question. I think it's time for you to ShowSomeEffort (follow the link and read it).
 
Yasin Kothia
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok what im having trouble finding information on is, After i used SAX Parser and telling it what information i want, it shows all the data i want in the 'console' or CMD Prompt, that's great but i now need to store that information on MySQL (Which is where im struggling to find information on how to do it).

My SAX Parser looks like this.

 
Paul Clapham
Sheriff
Posts: 28365
99
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
That's a much better question.

So instead of writing the data to the console, where as you imply it's of no use, store it in some variables in your program. And then use those variables as part of your code which writes rows to your MySQL tables.

(By the way you aren't using a SAX parser there. You are using a DOM parser.)

Edit: I had a look at the XML you are trying to process (by downloading it from the link in your code). So far you are getting down to the Element nodes which you want to write to the database, but you aren't finished. Each of those Element nodes has a single child which is a Text node, so for each of then you'll want code which gets that child, casts it to Text, and then extracts the actual contents of that Text node as a String. Those are the things you will want to store in variables so you can write them to the database.
 
Yasin Kothia
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help Paul and being so patience with me . Yeah i followed an example on another Forum he coded it claiming it was SAX :S i did look at many DOM and it did look similer, so i was confused, anyways i will try what you suggested and i will get back to you.
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic