• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

jdbc resultset to xml

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have to insert data into a database table using jsp and jdbc, query the table data and convert resultset into an xml file. I am using NetBeans IDE. I'm really stuck and i have a project due. Please do help.
Thanks in advance.
 
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
What have you written so far? What are you stuck on?
 
shru win
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to convert resultset into xml file. Inserting into database table and querying the contents of the table is done. But unable to generate xml file. . Please help.
 
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
XML is just well formatted text data. Are you familiar with the java.io package and writing to files? And are you comfortable going through a ResultSet and accessing its contents?
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I think Oracle gives you ability to fetch the data as XML itself. Might be helpful if you are fetching the resultset from Oracle.

Regards,
Amit
 
shru win
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.
I am using postgresql. I'm pretty comfortable with resultset. I'm using netbeans IDE. This can be easily done using PHP.But in netbeans i'm unable to use php in java projects. So stuck.
 
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
OK. So the steps will be:
  • move through your ResultSet and build up your formatted XML as a String
  • write it out to a file


  • Have you written the first bit? Or is that where you are stuck?
     
    shru win
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Actually that is where am stuck.
     
    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
    OK, well the JDBC tutorial will show you how to access things from your ResutlSet, and the basic io second of the Java tutorial will show you how to do the other other part.
     
    shru win
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I'v attached my code along with this. It's not working. This is the just a sample code i craetes to learn how it works. Inserting into database is perfectly working.
    Converting to xml is not. Please do tel me what m doing wrong.
     
    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
    A couple of points: saying "its not working" makes it difficult to help. You need to tell us what is going wrong, especially if there is a stack trace. The other is code in a JSP is bad. I know this is just to learn, but it actually makes things harder to develop.

    That aside, I don't see any code that saves or streams your Document?
     
    My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
    We need your help - Coderanch server fundraiser
    https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
    reply
      Bookmark Topic Watch Topic
    • New Topic