I'm trying to insert values into an existing java DB running on my local machine. My code:
void insertVal(String json){
Connection conn = null;
//DriverManager.registerDriver(new com.mysql.jdbc.Driver ());jdbc:mysql://localhost:3306/?user=root
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Orders", "root", "1234");
Statement st = conn.createStatement();
String insert = "INSERT INTO orders " + json;
st.executeUpdate(insert);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
It keeps saying java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/?user=root
I've added the JDBC driver given here Connect Java to a MySQL database (used independent platform)
and added it as a dependency using Intellij.
What am I missing?
Thanks!
EDIT: To anyone encountering this issue, this code is fine. my driver version wasn't the most updated one.