How to determine if I need db connection pooling?

akloaklo

Supremacy Member
Joined
Nov 15, 2004
Messages
7,252
Reaction score
19
I'm currently writing a task manager for my company.
The task manager will write to a table if a particular task was ran successfully.

It is highly possible that there will be at least 200 task per day and sometimes even 800 task in the span of 2-3 hours (or even 1hour)

Like I mentioned, for each task, I will have to update/insert/read data to my task table to change the status and some other variables.


So my code is currently:

conn.open()
//do things for each task (could even be concurrent task)
conn.close()


I'm using just Java (not J2EE) and my app NOT be running from an app server, it will just be a jar file which will be executed on a machine.

So how do you determine if I need pooling or not? How many connections are considered many?
Edit: it also seem that for db connection pooling, people only implement it on appserver like apache/tomcat? Is there no need to implement pooling for a program that simply just run without an appserver?
 

exim22

Member
Joined
Feb 7, 2007
Messages
374
Reaction score
0
It's a standalone desktop application? You can use SQLite or similar db that can work with desktop applications. Look up the resources online.
 

ykgoh

Master Member
Joined
Jan 1, 2000
Messages
2,785
Reaction score
0
If you have 1 task manager application writing to 1 database, you only need 1 persistent DB connection. No need for connection pooling at all. So connect once when your app is starting and remember to close it cleanly when app is terminating, perhaps wrap in some finally block. Also consider using a Singleton design to implement a DBConnectionManager to reuse an existing DB connection.

Connection pooling is only used when there are many different clients.

Inserting 800 records on modern database can be done in mere milliseconds or at most 1 or 2 seconds max even on commodity hardware. Performance should not be an issue.
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ. Forum members and moderators are responsible for their own posts.

Please refer to our Community Guidelines and Standards, Terms of Service and Member T&Cs for more information.
Top