I have this method here - whenever I comment out the MySQL section, from String query to pst.close() - the code works fine. However, if I don't, then it gives me the error of Connection Reset. I am using a socket between a client and a server for your information. How would I fix this? Or it it a problem that does not deal with MySQL?
public static String doAddUser(String username, String password, String email, String fullname) throws SQLException {
String returnStatement = "";
Connection connection = establishConnection();
if(email.isEmpty() || password.isEmpty()) {
returnStatement = "CreateFailure: Some fields are left blank. Please note that all fields are required. Please try again";
}
else {
String query = "insert into test(`username`, `password`, `email`, `fullname`) values (?,?,?,?)";
PreparedStatement pst = connection.prepareStatement(query);
pst.setString(1, username);
pst.setString(2, password);
pst.setString(3, email);
pst.setString(4, fullname);
pst.executeUpdate();
pst.close();
returnStatement = "CreateSuccess: You are now registered!";
}
return returnStatement;
}
establishConnectiondo?