我的笔记本式win7 64位的系统,安装的jdk是1.7.0_11的版本也同样是64位的。
在写一个验证登陆的处理servlet时,发现总是无法连接数据库。提示这样或者那样的错误。
错误提示如下,没有适合的驱动,我就纳闷了:
SEVERE: The web application [/myWebSite] registered the JDBC driver [com.microso
ft.sqlserver.jdbc.SQLServerDriver] but failed to unregister it when the web appl
ication was stopped. To prevent a memory leak, the JDBC Driver has been forcibly
unregistered.
进入loginCL页面
java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://l
ocalhost:1433;databaseName=spdb
at java.sql.DriverManager.getConnection(DriverManager.java:604)
at java.sql.DriverManager.getConnection(DriverManager.java:221)
at com.four.LoginCL.doGet(LoginCL.java:49)
at com.four.LoginCL.doPost(LoginCL.java:113)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcesso
r.java:879)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.pr
ocess(Http11AprProtocol.java:600)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:17
03)
at java.lang.Thread.run(Thread.java:722)
麻烦大家仔细看一下,提示一下该怎么解决这个问题?
另外:这个jar包应该放几个?
查了些资料,似乎不同版本的sql server 所放的jar包也是不同的,是这样吗?我不是很理解。。可以说一下原因么?
另外还有一个问题:加载驱动包的地址为什么都有一些微小的变化?是否影响代码的变异?比如:com.microsoft.sqlserver.jdbc.SQLServerDriver
数据库的url的连接:这样写是对的么?
DriverManager.getConnection
("jdbc:microsoft:sqlserver://localhost:1433;databaseName=data111"
,"sa","111111111");
还望你可以稍微看一下之后做一下解答,万分感谢!