在JSP文件中定义它:
<sql:setDataSource
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:microsoft.sqlserver://localhost:1433;databaseName=GP"
user="sa"
password="sa123"
var="dSource"/>
<sql:query dataSource="dSource" var="result">
SELECT * FROM GP.FE_ENROLL_DATA
</sql:query>
堆栈跟踪:
javax.servlet.jsp.JspException: Unable to get connection, DataSource
invalid: "java.sql.SQLException: No suitable driver found for dSource" at
org.apache.taglibs.standard.tag.common.sql
.QueryTagSupport.getConnection( QueryTagSupport.java:276) at
org.apache.taglibs.standard.tag.common
.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:159) at
org.apache.taglibs.standard.tag.el.sql.QueryTag.doStartTag(QueryTag.java:85) at
org.apache.jsp.enrollmentRecord_jsp
._jspx_meth_sql_005fquery_005f0(enrollmentRecord_jsp.java:477) at
org.apache.jsp.enrollmentRecord_jsp._jspService(enrollmentRecord_jsp.java:105) at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at
java.lang.Thread.run(Unknown Source)
您的连接网址是
url="jdbc:microsoft.sqlserver://localhost:1433;databaseName=GP"
据我所知,你的网址should be either
url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=GP"
对于SQL Server 2000.请注意:
而不是.
。它可以替代地具有形式
jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]
您的连接网址是:
url="jdbc:microsoft.sqlserver://localhost:1433;databaseName=GP"
将其替换为以下URL:
url="jdbc:sqlserver://localhost:1433;databaseName=GP"
要么:
url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=GP"