package com.example.hotel;
import com.mysql.jdbc.Driver;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class HelloApplication {
public static void main(String[] args) {
// TODO Auto-generated method stub
/* try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your MySQL JDBC Driver?");
e.printStackTrace();
return;
}*/
System.out.println("MySQL JDBC Driver Registered!");
Connection connection = null;
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager
.getConnection("jdbc:mysql//192.168.12.162:3306/HOTEL", "paco", "paco");
} catch (SQLException e) {
System.out.println("Connection Failed! Check output console");
e.printStackTrace();
return;
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
if (connection != null) {
System.out.println("You made it, take control your database now!");
} else {
System.out.println("Failed to make connection!");
}
}
}
Here's my code, as you can see, i try to do the connection but however i can't since it says the following:
Java.sql.SQLException: No suitable driver found for jdbc:mysql//192.168.12.162:3306/HOTEL
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:708)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:230)
at com.example.hotel/com.example.hotel.HelloApplication.main(HelloApplication.java:28)
I manage to solve some other erros i got but this one is freaking me out, i the IP address is correct and the user/password is correct too.