本篇内容主要讲解“java链接sql server 2000后出错的原因”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“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.
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
到此,相信大家对“java链接sql server 2000后出错的原因”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。