1把JDBC驱动部署在/WEB-INF/lib和Tomcat_Home/common/lib中。 2分步打印 Context jndiCntx = new InitialContext();System.out.println("Looking up jdbc/DefaultDS");DataSource ds = (javax.sql.DataSource)jndiCntx.lookup("java:comp/env/jdbc/DefaultDS");System.out.println("Found. Connecting to jdbc/DefaultDS");con = ds.getConnection();3.Your question asking if sqlodbc.jar was in $CATALINA_HOME/common/lib directory got me started down the right path. Tomcat 6 did away with the $CATALINA_HOME/common/lib directory. The correct place to put libraries that need to be loaded before your application starts is now in the $CATALINA_HOME/lib directory. Not sure why they chnaged this, but this was why Tomcat could not load the driver.这个问题挺普遍的 还不能确定是tom猫的bug...... 希望你解决后 总结下
2分步打印
Context jndiCntx = new InitialContext();System.out.println("Looking up jdbc/DefaultDS");DataSource ds = (javax.sql.DataSource)jndiCntx.lookup("java:comp/env/jdbc/DefaultDS");System.out.println("Found. Connecting to jdbc/DefaultDS");con = ds.getConnection();3.Your question asking if sqlodbc.jar was in $CATALINA_HOME/common/lib directory got me started down the right path. Tomcat 6 did away with the $CATALINA_HOME/common/lib directory. The correct place to put libraries that need to be loaded before your application starts is now in the $CATALINA_HOME/lib directory. Not sure why they chnaged this, but this was why Tomcat could not load the driver.这个问题挺普遍的 还不能确定是tom猫的bug......
希望你解决后 总结下