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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

threadlocal vs connection pool

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
OK, this might not be a beginning Java question. I am new to the forum and i apologize if this is not the correct place for this question.

Application gets a message from sender application.

opens a oracle db connection and stores the connection in threadlocal varaible

calls a whole bunch of classes passing the threadlocal variable to do some things to the data and store it in a oracle array

then continues to get more messages one at a time and does that same thing until it gets a commit messages from sender

when the whole set of array does a bunch insert to db

and releases the thread. and resets the threadlocal variable.


Now i saw multiple online didcussions on how threadlocal variables are not a recommended way to keep the db connection
and instead we should be using jdbc connection pool.

what i dont understand is, the jdbc connection pool is available and the threadlocal variable is merely getting a connection from the pool
and returning it back to the pool when it is done doing what it does.

i dont know what people mean when they say use jdbc connection pool instead

Also, do you guys think the above approach to handle db connections is a good way to go about this?

Any other better ways this could be done. I saw a forum where they recommend using Hibernate.

Please share your thoughts.

thanks.

 
Honk if you love justice! And honk twice for tiny ads!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
    Bookmark Topic Watch Topic
  • New Topic