当前位置: 代码迷 >> Java Web开发 >> 为什么会有java.sql.SQLException: No suitable driver的异常
  详细解决方案

为什么会有java.sql.SQLException: No suitable driver的异常

热度:37   发布时间:2016-04-17 15:38:23.0
为什么会有java.sql.SQLException: No suitable driver的错误?在线等
java.sql.SQLException:   No   suitable   driver
at   java.sql.DriverManager.getConnection(DriverManager.java:545)
at   java.sql.DriverManager.getConnection(DriverManager.java:171)
at   app.bean.DataBaseConnection.getConnection(DataBaseConnection.java:16)
at   app.action.RegisterBean. <init> (RegisterBean.java:14)
at   app.action.RegisterAction.execute(RegisterAction.java:25)
at   org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at   org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at   org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at   org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
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   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:856)
at   org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
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)

我已经把3个sqlserver的驱动拷到/web-inf/lib下,在jre/lib/ext下也拷进去了,并且在java   build   path-library-add   external   jars也包含进这3个jar了。为什么还报错?开发工具是eclipse

DataBaseConnection.java
import   java.sql.Connection;
import   java.sql.DriverManager;

public   class   DataBaseConnection   {
public   static   Connection   getConnection(){
Connection   con=null;
String   CLASSFORNAME= "com.microsoft.jdbc.sqlserver.SQLServerDriver ";
String   SERVANDDB= "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev ";
String   USER= "bn ";
String   PWD= "bn ";

try{
Class.forName(CLASSFORNAME);
con=DriverManager.getConnection(SERVANDDB,USER,PWD);
System.out.println( "connect   success ");
}catch(Exception   e){
System.out.println( "connecting   failded ");
e.printStackTrace();
}
return   con;
}

}

------解决方案--------------------
补丁呢?
------解决方案--------------------
我已经打了sp4的补丁了,可还是这样,看了不少关于这个问题的帖子,有些错误差不多,但修改后还是这样
------解决方案--------------------
版本不对吧.
看你用的是2000还是2005了,下个合适的驱动. 2005好像一个驱动文件就行了.
------解决方案--------------------
  相关解决方案