• 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

need an advice in JDBC coding !!

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

I need an advice in JDBC coding !!

In my project i need to write a servlet which parses an XML,
retrieves values of XML and invokes stored procedures using those values.

My servlet uses a Parserclass method
Map parsexml(string str) to parse the data. This method parses the data and return the parsed values as a HashMap.

My problem is ... i am not sure where to include my JDBC code to execute the stored procedures.

1) Should i write the jdbc logic in a method of the parserclass itself
[or]
2) should i write one more class which takes care of jdbc stuff
[or]
3)should i include the jdbc code in servlet.

I am using weblogicServer8.1 for the application and jdbc connection pool inorder to get the connection object.
I think if i have to use some other class to handle jdbc stuff, i should be passing this connection object to other class

methods.

I would like to know whether my approach is correct or not.
What would be the best approach in my cenario.
I am not able to properly judge as i am new to this.

Any help is appreciated,
Thanks in advance,
Pooja.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pooja,
I would go with option 2. It keeps the JDBC as separate as possible. Why would you need to pass the class a connection, rather than have the JDBC class get the connection itself?
 
Pooja Agarwal
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Jeanne Boyarsky

You are rite, there is no need to pass connection object as well.
I will obtain it in the JDBC class.

Thanks for ur advice.
I appreciate ur help
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic