• 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

Retrieving xm from mySQL and sending it through webservice method

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I am trying to export an xml outputted from mySQL database onto a mobile client.
The client will then parse the retrieved xml at the client end.

The problem I am facing is when I am trying to store the Query output to a variable which I can return via the service method to the mobile client.



I tried running the query on Toad and got the perfect output. The problem now is simply to send it back through the Webservice.


Please help
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Sadly, I must say that your code looks really ugly. Why do you mix querying the DB and generating the XML in a SQL query???
What do you do if you one day need to switch to another DB or another way of storing your data?
My advice is as follows:
1. Create an XML schema describing the XML you want to generate.
2. Use XJC and the XML schema to generate JAXB bean classes.

Then you implement code that does the following, step by step:
1. Query the database.
2. Create JAXB bean objects.
3. Insert data into the JAXB bean objects.
4. Use the JAXB bean object(s) to generate a response from the web service.
Best wishes!
 
Dushyant Chhetri
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Request you to direct me to some link about the knowledge you talked about.

I am new to JAXB and would want to learn more
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Of course!
Since I do not know at which level you are, I will provide several different links to material on JAXB. Please select the one you feel is most suitable to you. The references are in no special order.
  • JavaEE Tutorial on JAXB

  • http://java.sun.com/javaee/5/docs/tutorial/doc/bnazf.html

  • 5 Minutes on Java

  • http://ukumars.wordpress.com/2009/03/18/jaxb-in-5-minutes/

  • JAXB Example from My SCDJWS 5 Study Notes

  • See page 155 and forward in this document: http://faq.javaranch.com/content/Exam-Objectives-5.pdf

  • The JAXB Tutorial

  • https://jaxb.dev.java.net/tutorial/

    Please do not hesitate if you have any questions!
     
    Greenhorn
    Posts: 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Dush,

    I think JibX will be perfect for this.JiBX is a tool for binding XML data to Java objects.



    For more information you can Visit

    http://jibx.sourceforge.net/index.html
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic