Make DBCP Connection Pool Using Tomcat Resource Context

Setup JDBC DBCP (data base connection pooling) for use with any Java class.


How I set it up:
public DatabaseConnection(boolean pool) {
File executionlocation = null;
try {
executionlocation = new File(DatabaseConnection.class.getProtectionDomain().getCodeSource().getLocation().toURI());
} catch (URISyntaxException e) {
String execPath = executionlocation.getParent();
execPath = StringUtil.getValue("(.*?)/war", execPath);
String path = execPath + "/war/META-INF/context.xml";
String contextXmlPath = path;
String tmpPath = "/home/branflake2267/tmp";
// make my own context
SetupInitialContext ic = new SetupInitialContext(tmpPath);
context = ic.getInitialContext();

Post a Comment

Popular posts from this blog

How to Get Date/Time in/with GWT

Encoding URL delimiters (for GWT)