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);
}
}
}
I'm getting this Error:
SQLException: Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the main URL sections.
SQLState: 08001
VendorError0
I'm using this (C:\Users\ABDOU NASSER\Desktop\mysql-connector-java-8.0.11\mysql-connector-java-8.0.11.jar
) with the last eclipse version 2018
and as database XAMPP (MySQL)