why is it my Connection code not working? I have everything right password,user, and the host and the driver but why is it not working??
import java.sql.*;
public class Connection {
public String url = "jdbc:mysql://localhost:3306/Testdb";
public String driver = "com.mysql.jdbc.Driver";
public String user = "root";
public String pass = "123192";
public void JdbcConnection(){
try{
Class.forName(driver);
}catch(Exception e){
e.printStackTrace();
}
try{
Connection con = DriverManager.getConnection(url,user,pass);
}catch(Exception e){
e.printStackTrace();
}
}
}
Please change the name of your class (it must not a
Connectionespecially when you import thejava.sql.*) and you need to specify the username and password while obtaining a connection.