jetty配置JNDI

阅读更多

Jetty配置 JNDI的代码方式

在相应的web.xml也要加入相应的引用

	
		showcase Datasource
		jdbc/showcase
		javax.sql.DataSource
		Container
	



public class JettyServer {
	private static final int HTTPPORT = 80;
	private static Server server;
	private static final String CONTEXT = "/";

	public static void main(String[] args) throws Exception {

		Server server = new Server(HTTPPORT);
		WebAppContext webContext = new WebAppContext("src/main/webapp", CONTEXT);
		webContext.setClassLoader(Thread.currentThread().getContextClassLoader());
		
		ComboPooledDataSource pooledDataSource = new ComboPooledDataSource();
		pooledDataSource.setDriverClass("com.mysql.jdbc.Driver");
		pooledDataSource.setJdbcUrl("jdbc:mysql://113.108.228.101:3306/dim?useUnicode=true&characterEncoding=utf8");
		pooledDataSource.setUser("sdfsdd");
		pooledDataSource.setPassword("ssdsdasfd");
		new Resource("jdbc/showcase", pooledDataSource);
		
		server.addHandler(webContext);
		server.setStopAtShutdown(true);
		server.start();


	}

}

你可能感兴趣的:(jetty配置JNDI)