跪求高手解决,连接sql 2005 eclipse
代码如下:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<body>
<sql:update var="Emp" dataSource="${Employee}">
insert into Employee(UserName)
values('Jiang')
</sql:update>
</body>
</html>
补充:在sql 2005 中已建立数据库Employee,表Employee
提问:
dataSource="${}" 用的是什么参数,
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver";与上又不何不同
这是测试能不能在SQL中INSERT东西,不行,说明还没有建立连接吗?
错误如下:
org.apache.jasper.JasperException: An exception occurred processing JSP page /insert.jsp at line 5
2: <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
3:
4: <body>
5: <sql:update var="Emp" dataSource="${Employee}">
6: insert into Employee(UserName)
7: values('Jiang')
8: </sql:update>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handle
JspException(JspServletWrapper.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:442)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.ServletException:
javax.servlet.jsp.JspException: 'dataSource' is null
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp.insert_jsp._jspService(insert_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.jsp.JspException: 'dataSource' is null
org.apache.taglibs.standard.tag.common.sql.UpdateTagSupport.getConnection(Unknown Source)
org.apache.taglibs.standard.tag.common.sql.UpdateTagSupport.doStartTag(Unknown Source)
org.apache.jsp.insert_jsp._jspx_meth_sql_005fupdate_005f0(insert_jsp.java:94)
org.apache.jsp.insert_jsp._jspService(insert_jsp.java:63)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
------解决方案--------------------
建议楼主还是一步一步踏实地走吧,你这个JSP要正常执行数据库操作涉及到这样几个问题
第一,你用了数据源DataSource,需要事先在应用服务器那里配置好,你没配,
程序无法执行,'dataSource' is null 就是说的这个错误
第二,