Hey, how can i use dbcp with embedded tomcat7
this example doesn't work: public static void main(String[] args) throws Exception { String appBase = args[0]; Integer port = Integer.valueOf(args[1]); Tomcat tomcat = new Tomcat(); tomcat.setPort(port); tomcat.setBaseDir("."); tomcat.getHost().setAppBase(appBase); String contextPath = "/myapp"; // Add AprLifecycleListener StandardServer server = (StandardServer)tomcat.getServer(); AprLifecycleListener listener = new AprLifecycleListener(); server.addLifecycleListener(listener); tomcat.addWebapp(contextPath, appBase); tomcat.enableNaming(); tomcat.start(); // From http://commons.apache.org/dbcp/guide/jndi-howto.html Reference ref = new Reference("javax.sql.DataSource", "org.apache.commons.dbcp.BasicDataSourceFactory", null); ref.add(new StringRefAddr("auth", "Container")); ref.add(new StringRefAddr("factory", "org.apache.tomcat.jdbc.pool.DataSourceFactory")); ... InitialContext ic = new InitialContext(); ic.rebind("jdbc/basic", ref); InitialContext ic2 = new InitialContext(); DataSource ds = (DataSource) ic2.lookup("jdbc/basic"); tomcat.getServer().await(); } what's wrong? Can anybody help me? Regards, Holger --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org