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

wocawuliao 2014-05-18 02:48:50
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>

...全文
250 19 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
菜 头 2014-05-19
  • 打赏
  • 举报
回复
引用 18 楼 u011320740 的回复:
[quote=引用 7 楼 wocawuliao 的回复:] [quote=引用 6 楼 u011320740 的回复:] 端口呢???
应该是默认的8080吧?[/quote] jdbc:mysql://localhost/应该是这样的吧jdbc:mysql://localhost:[端口号]/[/quote] 加上端口3306
菜 头 2014-05-19
  • 打赏
  • 举报
回复
引用 7 楼 wocawuliao 的回复:
[quote=引用 6 楼 u011320740 的回复:] 端口呢???
应该是默认的8080吧?[/quote] jdbc:mysql://localhost/应该是这样的吧jdbc:mysql://localhost:[端口号]/
小小强0124 2014-05-19
  • 打赏
  • 举报
回复
还有那个驱动用错了吧
小小强0124 2014-05-19
  • 打赏
  • 举报
回复
引用 7 楼 wocawuliao 的回复:
[quote=引用 6 楼 u011320740 的回复:] 端口呢???
应该是默认的8080吧?[/quote] MySQL的端口是3306,就算是8080你也得写上啊
码无边 2014-05-19
  • 打赏
  • 举报
回复
Access denied for user 'soft'@'localhost' (using password: YES)
什么都不能 2014-05-19
  • 打赏
  • 举报
回复
引用 8 楼 wocawuliao 的回复:
[quote=引用 5 楼 hanpoyangtitan 的回复:] 访问数据库失败,用root能否正常连接?
root???谁的root?[/quote] 当然是mysql的root,新建用户似乎要指定连接请求的地址的
tony4geek 2014-05-19
  • 打赏
  • 举报
回复
你用个工具登看看 用户名,密码对不
wocawuliao 2014-05-19
  • 打赏
  • 举报
回复
引用 11 楼 rui888 的回复:
你用个工具登看看 用户名,密码对不
还真是配置sever.xml时候密码写错了。。。。
Kangaroo_007 2014-05-19
  • 打赏
  • 举报
回复
数据库连接错误, 检查是否导入jar包(java连接数据库 用的)之后,检查你的用户名和密码是否正确。 还有 你的mysql 服务是否已经开启!
wyx100 2014-05-18
  • 打赏
  • 举报
回复
引用 9 楼 driversky_ly 的回复:
首先看下你有包没有,驱动用错没有,然后你没有写数据库的端口
driversky_ly 2014-05-18
  • 打赏
  • 举报
回复
首先看下你有包没有,驱动用错没有,然后你没有写数据库的端口
wocawuliao 2014-05-18
  • 打赏
  • 举报
回复
引用 5 楼 hanpoyangtitan 的回复:
访问数据库失败,用root能否正常连接?
root???谁的root?
wocawuliao 2014-05-18
  • 打赏
  • 举报
回复
引用 6 楼 u011320740 的回复:
端口呢???
应该是默认的8080吧?
菜 头 2014-05-18
  • 打赏
  • 举报
回复
端口呢???
什么都不能 2014-05-18
  • 打赏
  • 举报
回复
访问数据库失败,用root能否正常连接?
wocawuliao 2014-05-18
  • 打赏
  • 举报
回复
[quote=引用 3 楼 zhulin2012 的回复:] com.mysql.jdbc.Driver 是这个吧 是要把org.gjt.mm.mysql.Driver改成com.mysql.jdbc.Driver 吗?
不是太高的手 2014-05-18
  • 打赏
  • 举报
回复
com.mysql.jdbc.Driver 是这个吧
wocawuliao 2014-05-18
  • 打赏
  • 举报
回复
引用 1 楼 Gemerl 的回复:
org.gjt.mm.mysql.Driver 是什么? 有这个驱动类吗?
额。。。这个我也不知道。。。。 我是看的这篇帖子http://blog.csdn.net/liuyan6374/article/details/5061677.....学着配置jsp mysql 和tomcat的!!!!
Gemerl 2014-05-18
  • 打赏
  • 举报
回复
org.gjt.mm.mysql.Driver 是什么? 有这个驱动类吗?

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧