日期:2014-05-17  浏览次数:20751 次

java 链接 mysql问题!!!!!!!!!!!
import java.sql.*;
class test_insert_db {
   public static void main(String[] args) throws InstantiationException, IllegalAccessException{
        try{
            Class.forName("com.mysql.jdbc.Driver");
        }catch(ClassNotFoundException e){
            System.out.println(e);
        }
        String url="jdbc:mysql://127.0.0.1:3306/mysql,root,123";
        try{
            Connection conn=DriverManager.getConnection(url);
        }catch(SQLException ex){
            System.out.println(ex);
        }         
    }
}


提示: java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)



我但是我可以登录啊:


用户名跟密码是没错的。
 String url="jdbc:mysql://127.0.0.1:3306/mysql,root,006249";换成 String url="jdbc:mysql://localhost:3306/mysql,root,006249";也是没用!
驱动我已经加载进去了!


Java MySQL

------解决方案--------------------
 con=DriverManager.getConnection ("jdbc:mysql://localhost/scutcs","","");//连接数据库的url  用户名和密码
------解决方案--------------------
检查下驱动包是否和当前数据库匹配,或者尝试用windows ODBC 配置数据源再连接。
------解决方案--------------------
引用:
Quote: 引用:

 con=DriverManager.getConnection ("jdbc:mysql://localhost/scutcs","","");//连接数据库的url  用户名和密码

scutcs这是什么??
数据库名