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).
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
Joined: Oct 08, 2008
This is a normal Java POJO and not a web application. Also no need to worry about killing or terminating the program.
Meet Gaurav wrote:yes it's an utility we are using.. Any others guys ?
Any new solution !!! or Suggestion !!!
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.