初学者:jsp+tomcat连接数据库mysql时出现这样的提示,什么原因呢??请求帮助。
jsp+tomcat连接数据库mysql时出现这样的提示:
java.sql.SQLException: Invalid authorization specification, message from server: "Access denied for user: 'system@localhost' (Using password: YES)"
什么原因呢??请求帮助。
连接程序是:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%
try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/test?user=system&password=system";
//testDBΪÄúµÄÊý¾Ý¿âÃû
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from shop";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
ÄúµÄµÚÒ»¸ö×ֶεÄÄÚÈÝΪ:<%=rs.getString(1)%>
ÄúµÄµÚ¶þ¸ö×ֶεÄÄÚÈÝΪ:<%=rs.getString(2)%>
<%}%>
<%out.print("Êý¾Ý¿â²Ù×÷³É¹¦,¹§Ï²Ä㣡£¡£¡");%>
<%rs.close();
stmt.close();
conn.close();
} catch(Exception e)
{out.println(e.toString()); }
%>
</body>
</html>
问题点数:20、回复次数:9Top
1 楼dachun(达达)回复于 2003-12-04 21:11:42 得分 1
jdbc:mysql://localhost/test?user=system&password=system&useUnicode=true&characterEncoding=gb2312
连接串出错,你在命令行方式用这用户名和密码能进吗?Top
2 楼zhaoyan310()回复于 2003-12-04 21:30:28 得分 0
我在我的计算机上装上mysql数据库后,提示输入用户名和密码,我就输入了system/system
。以后每次启动计算机时mysql就自动运行,并可以在命令行状态操作mysql的mysql和test
数据库。Top
3 楼gong1(轻松编程)回复于 2003-12-04 21:52:19 得分 1
好像是缺密码。
用户名啊。
哈哈Top
4 楼caoruomou(caoruomou)回复于 2003-12-04 21:53:40 得分 1
重新建一个新的用户名和密码Top
5 楼dbcat2002(老猫)回复于 2003-12-04 22:13:43 得分 14
jdbc:mysql://localhost/test?user=root&password=&useUnicode=true&characterEncoding=gb2312
这样就可以了。Top
6 楼keylee94(阿悦)回复于 2003-12-04 22:26:54 得分 1
用户的密码不对啊!(yes)Top
7 楼chasnoly(chasnoly)回复于 2003-12-04 22:36:03 得分 1
问题很明显,你的用户身份不对。就是密码错或用户名错。再者,要察看你的登陆身份是否正确。Top
8 楼skyyjl(ntsky)回复于 2003-12-04 22:50:24 得分 1
jdbc:mysql://localhost/test?user=system&password=system
在localhost后加上连接数据库的端口3306
jdbc:mysql://localhost:3306/test?user=system&password=system
在检查下用户名和密码
Top
9 楼zhaoyan310()回复于 2003-12-05 12:37:53 得分 0
感谢各位这个问题的关心,现在问题解决了!:)
jdbc:mysql://localhost/test?user=root&password=&useUnicode=true&characterEncoding=gb2312
这样就可以了。(dbcat2002(老猫))Top




