• 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

JDBC driver to read XML file

 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Can anyone tell me which JDBC driver can be used to read an XML file???

Saurabh
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jaxb is fantastic for reading XML. Look at suns jaxb home page for info
 
Saurabh Agrawal
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for clarifying everything.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic