jsp tomcat 连接mysql数据库遇到了问题!!!

wocawuliao wocawuliao 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
tomcat安装成功,数据库也建立成功

在浏览器中输入http://127.0.0.1:8080/myapp/first.jsp后出现如下提示
HTTP Status 500 - javax.servlet.ServletException: java.sql.SQLException: Access denied for user 'soft'@'localhost' (using password: YES)

type Exception report

message javax.servlet.ServletException: java.sql.SQLException: Access denied for user 'soft'@'localhost' (using password: YES)

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

这个改怎么解决!!!!???

jsp代码如下
<%@ page contentType="text/html;charset=gb2312"%> 
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/softforum?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1";
//first为你的数据库名
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from first";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>

...全文
评论 19
收藏 已收藏
分享
返回顶部
wocawuliao
Web 开发 81,107 成员 341,720 内容