I have a mysql db running on localhost. Database name is 'iot' and table name is 'iot'. I'm trying to connect but when checking if connection is null it is. Where am I going wrong?
I have these class variables:
private Connection connection;
private String server = "localhost:8090";
private String db = "iot";
private String username = "root";
private String password = "";
private String url = "jdbc:mysql://" + server + "/" + db;
In constructor:
Class.forName("com.mysql.jdbc.Driver").newInstance();
this.connection = DriverManager.getConnection(url, username, password);
Test:
if(connection == null){
System.out.println("null"); //prints unfortunately
}