aspose file tools*
The moose likes JDBC and the fly likes Java Database connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Java Database connection" Watch "Java Database connection" New topic
Author

Java Database connection

Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
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

Joined: Jul 24, 2009
Posts: 69

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

Joined: Oct 08, 2008
Posts: 492
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

Joined: Feb 24, 2006
Posts: 6661
    
    5

This is why we have connections pools


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
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

Joined: Feb 24, 2006
Posts: 6661
    
    5

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

Joined: Oct 08, 2008
Posts: 492
Problem is here we don't have any server to pool the connection.
mahesh shinde
Ranch Hand

Joined: Jul 24, 2009
Posts: 69

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

Joined: Oct 08, 2008
Posts: 492
yes it's an utility we are using.. Any others guys ?

Any new solution !!! or Suggestion !!!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41874
    
  63
Please restrict yourself to single exclamation marks; also note that in questions it's customary to use question marks instead.


Ping & DNS - my free Android networking tools app
nimish kumar
Ranch Hand

Joined: Dec 04, 2009
Posts: 56
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.


IBM-IBM WebSphere Application Server Network Deployment V7.0, Core Administration.
Prabhakar Reddy Bokka
Ranch Hand

Joined: Jul 26, 2005
Posts: 189

You can use "Object Pooling" technique, which exactly works as Connection Pooling in your standalone java application.
Is that satisfies your requirement?


SCJP 5, SCWCD 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Database connection