I am creating a JavaFX application with IntelliJ and I am trying to add data to a MySQL DB. The problem I am getting is No Suitable driver found.
I have created a datasource within IntelliJ with the following settings: datasource settings Driver settings
I have tried other ways as specified in other threads, but still get the same issue.
The Code I am running to establish the connection and run a statement is as follows:
public void connectToDB() throws SQLException{
String host = "jdbc:mysql://localhost:3306/librarycollection";
Connection con = DriverManager.getConnection(host,"root","password");
PreparedStatement statement = con.prepareStatement("INSERT INTO user_table VALUE ?,?,?,?,?");
statement.setString(1,firstName_field.getText());
statement.setString(2,lastName_field.getText());
statement.setString(3,username_field.getText());
statement.setString(4,email_field.getText());
statement.setString(5,registerPasswordConfirm_field.getText());
statement.execute();
}
Am I missing code within my method or is this something to do with the configuration?
This is not a duplicate as it may refer to the configuration of JavaFX, I have a driver installed and server running as a process. I am able to connect through intellij's 'Test Connection' with all the parameters and it comes back successful.
The code I have is the same as all other threads and is not required to put Class.forName() etc. as this is included in the Driver 4.0 (which I am using).