jsp连接数据库SQLServer2008在tomcat环境下打开网页出现错误,求高手解答原因

mimohy 2014-05-15 06:37:54
<%

// ***************** 数据库连接代码 开始 *****************



String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String url = "jdbc:sqlserver://localhost:1433; DatabaseName=JDGL";
String user = "sa";
String password = "";
Class.forName(driverName);
Connection conn=DriverManager.getConnection(url, user, password);


//建立连接
//Connection conn= DriverManager.getConnection(url);
// **** 数据库连接代码 结束 *********
%>




org.apache.jasper.JasperException: An exception occurred processing JSP page /ConnDB.jsp at line 14

11: String user = "sa";
12: String password = "";
13: Class.forName(driverName);
14: Connection conn=DriverManager.getConnection(url, user, password);
15:
16:
17: //建立连接


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:412)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

javax.servlet.ServletException: com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'sa' 登录失败。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
org.apache.jsp.index_005fMain_jsp._jspService(index_005fMain_jsp.java:220)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'sa' 登录失败。
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:196)
com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:246)
com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:83)
com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2532)
com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:1929)
com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:1917)
com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4026)
com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1416)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1061)
com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716)
com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841)
java.sql.DriverManager.getConnection(DriverManager.java:582)
java.sql.DriverManager.getConnection(DriverManager.java:185)
org.apache.jsp.index_005fMain_jsp._jspService(index_005fMain_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
...全文
64 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
Mr_Nice 2014-05-16
用户名,密码 注意一下。
回复
t101lian 2014-05-16
回复
美到心痛 2014-05-15
不懂.不过把服务器的sa设密码,然后代码中不用空密码试一下
回复
相关推荐
发帖
疑难问题
创建于2007-09-28

2.1w+

社区成员

MS-SQL Server 疑难问题
申请成为版主
帖子事件
创建了帖子
2014-05-15 06:37
社区公告
暂无公告