I'm following a tutorial and am completely new to JDBC, I have solid knowledge on Java and brief knowledge on SQL. I have an online VPS which has a small database in it(Just using it to learn this) but keep getting errors when:
- Registering the driver
- Opening a connection
Here is my simple class. If anyone could help, would be greatly appreciated.
import java.sql.*;
public class ExampleJava {
static final String USER = "HIDDEN_USERNAME";
static final String PASS = "HIDDEN_PASSWORD";
static final String DB_URL = "studiobooch.x10.mx";
static Connection conn;
public static void main(String[] args) {
System.out.println("Connecting to database");
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("DB_URL", USER, PASS);
}catch(SQLException e){
System.out.println("Connection error");
e.printStackTrace();
}catch(ClassNotFoundException e) {
e.printStackTrace();
}
}
}
Prints out the following:
Connecting to database
java.sql.SQLException: No suitable driver found for studiobooch.x10.mx
at java.sql.DriverManager.getConnection(DriverManager.java:596)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at ExampleJava.main(ExampleJava.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)