主要用到jndi技术
javax.naming.Context cxt=new InitialContext();
Context envCtx = (Context) cxt.lookup("java:comp/env");
javax.sql.DataSource ds = (DataSource)
envCtx.lookup("jbbc/SIMPLE");
这样就获得了数据源对象
其中
web.xml文件配置:
jbbc/SIMPLE为tomcat中连接池的名称