File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Best Practices with JDBC->Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Best Practices with JDBC->Object" Watch "Best Practices with JDBC->Object" New topic
Author

Best Practices with JDBC->Object

Kevin G Scott
Greenhorn

Joined: Jan 24, 2005
Posts: 17
Hello,
I am working on updating a client's Web Services to JAX-RPC and I'm not sure what the best solution is to returning large sets of objects out of the database. As I see it there is basically three solutions:
1) Store the objects in the datbase and just pull those directly out
2) Leave the code which currently exists that brings the information from the database and then add some JAXB to bind the XML that the current code returns to bridge to objects.
3) Rewrite so that the program instantiates some object, and then set each field by hand from the resultset

I think 1 is out because it would require too much monkeying around with the client's DB. So my choice is between 2 and 3. I don't see eithier as difficult to implement, but I'm not sure how they will compare from a speed/resources usuage perspective. Does anyone have any guidance, or at least an opinion?

Thanks in advance!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

Kevin,
Welcome to JavaRanch!

Personally, I like option #2. It is cleaner because it allows you to keep all the binding code in a separate layer. Obviously it isn't going to perform better than the existing solution, but I don't think option #3 will either. However, I don't think it will perform noticeably worse. If you really think performance is an issue, you could create a small dummy test program to try it out and see.

(Option #3 seems valid too. So it is more of a matter of personal preference.)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Kevin G Scott
Greenhorn

Joined: Jan 24, 2005
Posts: 17
Thanks for your reply,
I started writing some code using the 2nd solution (i.e. leave current code and then do JAXB to bind to an object). The problem that I ran into with that is that when I create the JAXB binding classes, they involve collections, which you can't do with JAX-RPC. I may move into a more appropiate forum and ask about methods around this.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

Kevin,
I'm moving this post into our web services forum for you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best Practices with JDBC->Object