File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes JDBC, Xml and servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC, Xml and servlets" Watch "JDBC, Xml and servlets" New topic

JDBC, Xml and servlets

Harry Singh
Ranch Hand

Joined: May 02, 2001
Posts: 124
i am just a starter . and i just wanna know how can i use xml, JDBC, and servlets together.. i mean can i use JDBC and XML together in a very effective manner... but thenwhat willbe the flow.. i am confused.. can anyone guide me through!!
Joe McGuire
Ranch Hand

Joined: Mar 19, 2001
Posts: 293
What is it you are trying to do? Do you want to use a servlet to retrieve a result set into an xml file?
XML is not a kind of relational database, so there really is no JDBC driver for XML. However, XML does have something that works the similarly: SAX.
SAX is an event based API for xml.
The details of using the sax parser to extract data into an xml file are fairly lengthy but straightforward. If you're interested there is an article in JavaWorld which details exactly how to this.
Hope this helps!
[This message has been edited by Joe McGuire (edited June 13, 2001).]
Andrew Shafer
Ranch Hand

Joined: Jan 19, 2001
Posts: 338

The question is not can you use this or that technology together, but rather is this technology a good approach to solving my problem.
What are you trying to accomplish? If we know that, we can suggest technology that is suited to your goal.

Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
If ur question is to combine all these technologies together, then here's the answer in breif.
First retrieve data from DBMS using JDBC and build a XML file using SAX or DOM API's. Then, use servlet to send this XML file to different server( XML is better chosen for EDI ie., in B2B scenario) and use parser at other side of server (use Servlet to get XML file over HTTP) to extract the XML file and update the database using JDBC.
Or else if u wanna send XML file to browser use some style sheets (XSL or CSS) to be displayed in browser as all browsers can't understand XML file, only IE(Internet Explorer) has built-in parser. U can use these style sheets at server-side or at client-side. there is a good explanation abt these XML/XSL forum.

SCJP 1.5, SCEA, ICED (287,484,486)
Harry Singh
Ranch Hand

Joined: May 02, 2001
Posts: 124
hi Gurus,
Thanks!! i think i got what i wanted...
I agree. Here's the link:
subject: JDBC, Xml and servlets
It's not a secret anymore!