• 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

Java Database connection

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


I have a java program in that am connecting oracle database and inserting more records then reading some files again updating the database. Since keep on interacting with DB.

Connection seems very expensive time.

Am planning to reuse the same connection. Opening a connection and keep on inserting records then committing the connection object then reading some file again inserting in DB and committing. While terminating the program am closing the connection (In Between am simply committing without closing the connection).

The program will run more than 15 hrs a day.

This is a good design any suggestions please
 
Ranch Hand
Posts: 69
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
suppose one scenerio you close your connection if user presses the Exit button .
but if user close application using windows upper right corner button then your close connection method wont invoke.
that connection still live.You will get out of resources soon
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mahesh,

This is a normal Java POJO and not a web application. Also no need to worry about killing or terminating the program.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is why we have connections pools
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Deepak,

Yes I agree... Since this is POJO I don't have any other option.. Please suggest we can proceed further or some other suggestion..

Deepak,

I have some other questions for you in Weblogic, I will post it there .
 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure what you mean. Use the POJO to lookup a Connection from a datasource that pools connections. That should do it.

If you are using tomcat, you can couple that with commons DBCP
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem is here we don't have any server to pool the connection.
 
mahesh shinde
Ranch Hand
Posts: 69
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
means its an utility, you run it for some specific reason(hope I get it correct).
then I am agree with Your approach.
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes it's an utility we are using.. Any others guys ?

Any new solution !!! or Suggestion !!!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please restrict yourself to single exclamation marks; also note that in questions it's customary to use question marks instead.
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Meet Gaurav wrote:yes it's an utility we are using.. Any others guys ?

Any new solution !!! or Suggestion !!!



Hi Gaurav,
Will making singleton class and creating your db connection in singleton class solve your problem. In this way, your application will make a single instance of the class and hence db connection will be made only once. Then you can perform you db operations like insert,update etc, and revoke connection at the end. I am not sure, need others suggestion.
 
Ranch Hand
Posts: 198
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use "Object Pooling" technique, which exactly works as Connection Pooling in your standalone java application.
Is that satisfies your requirement?
 
reply
    Bookmark Topic Watch Topic
  • New Topic