tomcat配置sql server2005连接池

我在context.xml中写入<Contextreloadable="true"crossContext="true"> <Resource... 我在context.xml中写入<Context reloadable="true" crossContext="true"> <Resource  name="jdbc/chat"  auth="Container" type="javax.sql.DataSource" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://localhost:1433;DataBaseName=db_login" username="sa" password="123456" maxActive="100" maxIdle="30" maxWait="1000"/></Context>在web.xml中加入<resource-ref>   <description>chat</description>       <res-ref-name>jdbc/chat</res-ref-name>   <res-type>javax.sql.DataSource</res-type>   <res-auth>Container</res-auth>   </resource-ref>  然后数据库连接写public Connection getConnection() throws SQLException  {       Connection con =null;  try {    Context ctx = new  InitialContext();   DataSource source=(DataSource)ctx.lookup("java:comp/env/jdbc/chat");   //Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");    con = source.getConnection();  } catch (NamingException e2) {   // TODO Auto-generated catch block   e2.printStackTrace();  }  return con; } 但是我运行程序的时候会出现Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'错误 展开
 我来答
仙王座miu星
2011-12-14 · TA获得超过705个赞
知道小有建树答主
回答量:455
采纳率:0%
帮助的人:204万
展开全部
你把 SQLServer 的驱动程序包 .jar 要放在 tomcat/lib下,或tomcat/webapps/yourApp/WEB-INF/class/lib 下,否则它找不到驱动程序
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式