格式错误的数据库网址无法解析主要网址部分

时间:2018-05-12 23:24:43

标签: java mysql

package miniproject;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Mysql_connection {

    private Connection con=null;
    private Statement st=null;
    private ResultSet res=null;
    public Mysql_connection() {
    try{        
            //Class.forName("com.mysql.jdbc.Driver");

            con=DriverManager.getConnection("jdbc:mysql:‪//localhost:3306/miniprojectdb","root","");
            st=con.createStatement();

    }catch(SQLException e)
    {
        System.out.println("SQLException: "+ e.getMessage());
        System.out.println("SQLState: "+ e.getSQLState());
        System.out.println("VendorError"+ e.getErrorCode());   
    }
    }
    public void Data(){
    try{        
        String query="select * from produit";
        res=st.executeQuery(query);
        System.out.println("========================="); 
        while(res.next()){
            int a=res.getInt(1);
            String b=res.getString(2);
            int c=res.getInt(3);
            System.out.println("ProdID:"+a+" "+"ProdNom:"+b+" "+"Prix/Tonne:"+c);
        }
    }catch(Exception e){ 
        System.out.println(e);  
    }   
    }

}

我收到此错误:

  

SQLException:由于底层而无法加载连接类   exception:com.mysql.cj.exceptions.WrongArgumentException:格式错误   数据库URL,无法解析主URL部分。

     

SQLState:08001

     

VendorError0

我使用这个(C:\Users\ABDOU NASSER\Desktop\mysql-connector-java-8.0.11\mysql-connector-java-8.0.11.jar)和最后一个eclipse版本2018 和数据库XAMPP(MySQL)

enter image description here enter image description here enter image description here

0 个答案:

没有答案