What feature/function are your trying to address with maintaining a DB connection? Perhaps if share the basics of what you need to do, we can offer approaches.
The JDBC adapter, which I assume you’re using (WmDB shouldn’t be used), provides for configuring a connection, as you’ve presumably done using IS Administrator. In that configuration, you configure the size of the connection pool. The pool will keep connections to the DB per that configuration (setting the min pool size above 0 is generally not a good idea).
There are a few items that you’ll need to address.
-
Where to get the connection parameters. You’ll either need to use non-public methods to get configuration information from a WmDB connection or a JDBC adapter connection; or you’ll need to store the information in a file somewhere (not a big deal, but just another thing to manage)
-
Where to store the connection(s) once you create them.
-
How to manage multiple threads that will want to use the connection(s).
-
How to clear/drop the connection when the DB has restarted or when the connection is stale (DB dropped the connection due to idle).
These things aren’t overly difficult but why reinvent the wheel? The JDBC adapter connection pool is most likely the right way to do what you need to achieve.
Again, if you can share what you need to do that led you to want to use Java and a persistent connection, then we can confirm that the JDBC adapter is the way to go and if not, we can help with alternatives.
#Flow-and-Java-services#webMethods#Integration-Server-and-ESB