aspose file tools*
The moose likes XML and Related Technologies and the fly likes Storing SAX Parser data into MySql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Storing SAX Parser data into MySql" Watch "Storing SAX Parser data into MySql" New topic
Author

Storing SAX Parser data into MySql

Yasin Kothia
Ranch Hand

Joined: Sep 25, 2009
Posts: 39
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.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Sep 25, 2009
Posts: 39
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Sep 25, 2009
Posts: 39
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.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

As it involves XML and SAX parser, moving it to XML forum to start with.


Mohamed Sanaulla | My Blog
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Yasin Kothia wrote:Thanks.


So your problem is solved, then? Excellent!
Yasin Kothia
Ranch Hand

Joined: Sep 25, 2009
Posts: 39
Sorry no not solved, I need help putting the data into MySql after using sax to parse it.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Sep 25, 2009
Posts: 39
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Sep 25, 2009
Posts: 39
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing SAX Parser data into MySql