java 链接sql server 2000 问题

java 链接sql server 2000 总结

Context envContext = (Context)initCtx.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/jieba");
conn = ds.getConnection();

执行后总是出现:

java.lang.NoSuchMethodError: com.microsoft.util.UtilDebug.setPrintWriter(Ljava/io/PrintWriter;)V
at com.microsoft.jdbc.base.BaseDriver.setupDebugging(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:877)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at com.hero.analysis.service.base.DBConnection.getConnection(DBConnection.java:41)
at com.hero.analysis.service.base.JDBCFacade.getDataSource(JDBCFacade.java:72)
at com.hero.analysis.service.base.JDBCFacade.(JDBCFacade.java:43)
at com.hero.analysis.dao.mysql.MysqlUserDAO.login(MysqlUserDAO.java:50)
at com.hero.analysis.service.UserBO.login(UserBO.java:27)
at com.hero.analysis.web.user.LoginAction.execute(LoginAction.java:39)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.hero.analysis.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:121)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.hero.analysis.util.CheckLoginFilter.doFilter(CheckLoginFilter.java:90)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)

跟着程序走了以下,确实没有这个方法,郁闷了一天

经过反复调试后发现有几种可能造成这个原因

1.驱动程序的版本不对

2 .sql server 2000没有打补丁 必须打补丁

3 .检查sql server 2000 的驱动程序mssql.jar,msbase.jar,mssqlserver.jar,msutil.jar存放位置对不对,一般放在tomact/commen/lib下就可以,或放进class_path,或webinfo/lib下,一般情况下,放一个地方就可以了

4 .位置方对了还不行 那可以考虑jdbc驱动程序的版本对不对,如果你打了 sp2补丁 那么也要用for sp2 driver

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/750220/viewspace-912034/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/750220/viewspace-912034/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值