File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best Practices with JDBC->Object

 
Kevin G Scott
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 33691
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
Kevin G Scott
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 33691
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kevin,
I'm moving this post into our web services forum for you.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic