Can connection poolong be implemented in the simple java class?

G

Garg

Good Morning All,

I am having a small confussion, can we implement connection pooling in
a simple java program with main method.

Thanks
Tarun Garg
 
G

Garg

basically i have to use persistent database connection. and i am
planning to achive that by pooling JDBC connection.
 
B

Brzezi

czw, 29 mar 2007 o 06:23 GMT, Garg napisa³(a):
I am having a small confussion, can we implement connection pooling in
a simple java program with main method.

Yes, you can, use for example DBCP

Pozdrawiam
Brzezi
 
S

Stan

Garg said:
Good Morning All,

I am having a small confussion, can we implement connection pooling in
a simple java program with main method.

Thanks
Tarun Garg

Yes, you can very easily, but you should probably not be asking this
question yet. Since it is generally very simple to retrofit such pooling
into an application, you should probably build the application without
pooling, and only implement it if required after performance profiling
the application. You can help yourself with a possible retrofit by
centralising method calls to obtain connections - then only that method
needs changing. Anyhow, main thing is...don't optimise until you need
to, and pooling is definitely such an optimisation.

If you find you do need connection pooling, there are many out there
that could achieve what you want, for example:
Jakarta DBCP (as already mentioned)
Proxool
DBPool
etc.

Stan
 
G

Garg

As i am writing a very simple java program with main thread, so i want
to mine own utility for this. But i am not getting the steps to write
the pool.

what i am planning is to write a static connection and use it and
whenever it throws a SQLException make another database connection.

Can i achive my goal through this?

thanks
Tarun Garg
 
S

Stan

Garg said:
As i am writing a very simple java program with main thread, so i want
to mine own utility for this. But i am not getting the steps to write
the pool.

what i am planning is to write a static connection and use it and
whenever it throws a SQLException make another database connection.

Can i achive my goal through this?

thanks
Tarun Garg

In my opinion the main art of the programmer is being able to translate
from a set of requirements into a workable algorithm. What you propose
seems very achievable, but I don't think using a connection pool will
necessarily help you solve the problem, as it seems more likely a
conceptual programming problem.

If this is not the case then I apologise for my assumption, but if so I
suggest the best solution to your problem is to find information on the
essentials of object-oriented programming in Java, and also JDBC
programming.

Stan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top