当前位置: 代码迷 >> Java Web开发 >> JSP 连接 Sql Server 2005 出错,请高手帮忙!解决方案
  详细解决方案

JSP 连接 Sql Server 2005 出错,请高手帮忙!解决方案

热度:360   发布时间:2016-04-17 10:42:25.0
JSP 连接 Sql Server 2005 出错,请高手帮忙!
HTTP Status 500 -
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /database/sql.jsp at line 10

7: ResultSet rs = null;
8: Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); 
9: String url="jdbc:sqlserver://localhost;integratedSecurity=true;DatabaseName=student";  
10: conn=DriverManager.getConnection(url); 
11: String sql="select * from Student";
12: stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);  
13: rs=stmt.executeQuery(sql); 

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

javax.servlet.ServletException: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]用户 '' 登录失败。该用户与可信 SQL Server 连接无关联。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp.database.sql_jsp._jspService(sql_jsp.java:108)
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:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)



------解决方案--------------------
你登录数据库难道不用账号和密码么

只有一个url不能连接数据库诶、

10: conn=DriverManager.getConnection(url,username,passsword);


------解决方案--------------------
你的username和password呢?
10: conn=DriverManager.getConnection(url,username,passsword);
------解决方案--------------------
conn=DriverManager.getConnection(url,username,passsword);
------解决方案--------------------
把你连接sql server的代码贴出看看,就知道拉。
------解决方案--------------------
你的sql jdbc是放在哪里?
------解决方案--------------------
探讨

String url="jdbc:sqlserver://localhost;integratedSecurity=true;DatabaseName=student";


不用端口号的啊?

------解决方案--------------------
探讨
你登录数据库难道不用账号和密码么

只有一个url不能连接数据库诶、

10: conn=DriverManager.getConnection(url,username,passsword);

------解决方案--------------------
探讨
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 10 in the jsp file: /database/sql.jsp
sa cannot be resolved to a variable
7: ResultSet rs = null;
……

------解决方案--------------------
[Quote=引用:]
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!
 
  • 最近登录:Sat Jul 21 23:48:17 CST 2018
  • 最近登录:Sat Jul 21 23:48:17 CST 2018
  • 最近登录:Sat Jul 21 23:48:17 CST 2018
  • 最近登录:Sat Jul 21 23:48:17 CST 2018
  • 最近登录:Sat Jul 21 23:48:17 CST 2018