Friday, February 19, 2010

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();

No comments:

Trying out the Dart Analysis Server

I wanted to see how the Dart Analysis Server was put together and worked. I started looking to see how I could wire it up and try out the co...