试了很久,也查了很多资料。求好心人帮助!!首先安装好了mysql后,能正常登陆。在可视化工具sqlyog中也能连接就是在jdbc中会报错:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)代码如下:public class demo1 {

/*// jdbc:数据库协议:主机:端口:数据库名称
private String url = "jdbc:mysql://localhost:3306/test";
private String user = "root";
private String pwd = "root123";*/

@Test
public void testSql() throws SQLException{
Properties properties = new Properties();
properties.setProperty("user", "root");
properties.setProperty("pwd", "root123");

Driver driver = new org.gjt.mm.mysql.Driver();
Connection connect = driver.connect(url, properties);
System.out.println(connect);
}
}若能得到帮助,感激不尽!!!奉上全部积分的家当!