Does connection pooling db connections make sense when java code is called from a shell script, or is it better to use individual connections? Doesn’t the jvm exit after every call to the shell script, forcing the db pool/factory/etc to be re-created each time the script is called?
For example, I have an external process that makes calls to a shell script, this shell script then calls a java class which executes 1 or more DB operations (query, insert, update, delete.), depending on the invoked operation. This is a standalone batch process which does not use a servlet container like tomcat. This shell script gets called by my external process over and over.
My environment is a bash shell script calling a java application (main() method) which utilizes spring jdbc and commons-dbcp 1.4 for it db processing and pooling.
Thanks in advance!
In your case, a connection pool probably only has a limited benefit, since you rightly said that whenever the JVM is shut down and started again, you would have to create the connection pool again. You could still use the pool if you want to benefit from using the
DataSourceinterface instead of creating the connection directly. If your processing is done in a single thread, make sure that the size of the connection pool is only 1.If you’re using multiple threads in the same process, then the connection pool probably makes more sense and you could benefit from its features.