File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clone DBConnection Object

 
Shankar sanjay
Ranch Hand
Posts: 117
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


I understand that Deep copy (clone) will return new separate object. So I am thinking like this..

i will create a DB connection object(say dbConnection) while my application start up, and stored it in cache. After that, whenever data base connection require then i will get a clone of dbConnection and try to process further.

can you please advice, this will be a good approach?

 
Martin Vajsar
Sheriff
Pie
Posts: 3747
62
Chrome Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This (most probably) is not going to work. Not all objects are cloneable. A database connection has to be established by calling the database server and it keeps some communication channel to the database open, these things from their very nature are not cloneable.

That said, a database connection might implement the Clonable interface and make sure to actually open a new connection when cloned, however I'd say no JDBC driver does so. It does not make much sense. A Connection Pool is usually used to re-use connection resources.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic