• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Database connection

 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • 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
 
mahesh shinde
Ranch Hand
Posts: 69
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is why we have connections pools
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • 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
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
yes it's an utility we are using.. Any others guys ?

Any new solution !!! or Suggestion !!!
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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.
 
nimish kumar
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • 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.
 
Prabhakar Reddy Bokka
Ranch Hand
Posts: 197
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic