当前位置: 代码迷 >> Sql Server >> java 链接 mysql有关问题!
  详细解决方案

java 链接 mysql有关问题!

热度:375   发布时间:2016-04-24 21:56:06.0
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这是什么??
数据库名
  相关解决方案