aspose file tools*
The moose likes JDBC and the fly likes JDBC driver to read XML file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC driver to read XML file" Watch "JDBC driver to read XML file" New topic
Author

JDBC driver to read XML file

Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
Hello,
Can anyone tell me which JDBC driver can be used to read an XML file???

Saurabh


Success is not doing extraordinary things but doing ordinary things extraordinarily well.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You want to use JDBC to perform file system IO? Why not use the java.io package for that? Or a parser from javax.xml.parsers?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Cameron McEwan
Greenhorn

Joined: Feb 25, 2005
Posts: 4
jaxb is fantastic for reading XML. Look at suns jaxb home page for info
Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
Hi ,
I knwo jAXB is an option which is more efficient and use to use as well.But someone asked me to use JDBC.So is it possible to read XML file using JDBC driver.
If yes how can it be done ?

Saurabh
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

There are products like Sunopsis XML Driver which do this. Personally I don't see the benefit - the big "benefit" seems to be the ability to query a document with SQL. Don't know why you might want to do this, since XPath is not too difficult to get to grips with.
Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
Thanks a ton for your reply.But Sunopsis XML Driver is a paid one and i am looking for some free ware.

Morever i wanna use it with my JBOSS.I.e. i dont want to open an input stream and simply want to do it with my J2EE container.

So i create a service and specify the driver JDBC to read a file for me.

So any comments on this ?
Saurabh
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Sunopsis is the only one I know about. I can see why you might need JDBC if by "i wanna use it with my JBOSS" you mean you want to parse this XML from an EJB and can't use file IO. In which case why don't you either store the XML in the DB, or use a JCA adapter for file system access?
Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
I guess JCA adapter needs us to specify the JDBC driver which we would need ? Am i rite at it?
Anyways You were right at what i am trying to do .

Saurabh
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346
why don't you either store the XML in the DB, or use a JCA adapter for file system access?


If a file can be saved in all kinds of databases?( I just know of ORACLE in this context). I asked this question because in case while developing the project, one doesn't know what database might be used in future.

To use JCA adapter for reading a file (while taking it as a datasource), we need to specify the jdbc driver class in xxx-ds.xml.

or

if we don't use jdbc driver then I suppose we have to write the implemenation code for JCA resource adabtor to read/write xml file.

If we write JCA resource adabtor then how do we configure it in xxx-ds.xml file?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


If a file can be saved in all kinds of databases?( I just know of ORACLE in this context). I asked this question because in case while developing the project, one doesn't know what database might be used in future.

I'd hope so, though I can't say for sure. Every RDBMS I've used can support CLOBS or BLOBs etc. (or LONG RAW on older Oracle versions). But I wouldn't claim to know about all possible DBs so I suggest you do some checking if you are concerned.


To use JCA adapter for reading a file (while taking it as a datasource), we need to specify the jdbc driver class in xxx-ds.xml.

You need to specify a "driver" - but would be a driver for the resource you are trying to access, so its not a JDBC driver it would be some kind of File System resource adapter.


if we don't use jdbc driver then I suppose we have to write the implemenation code for JCA resource adapter to read/write xml file.

Yes. Or do some Googling for one that someone else has written. I can't think of one off the top of my head.


If we write JCA resource adabtor then how do we configure it in xxx-ds.xml file?

That's covered in JBoss's docs
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346
Thank you for clarifying everything.
 
jQuery in Action, 2nd edition
 
subject: JDBC driver to read XML file