I have no idea what wrong is with my sample code, I've followed all instructions on multiple YouTube videos and other online sources. I just can't fix it. Could someone explain what is the problem and how to solve it? All the required lib's are already added.
I have made sure all the libraries are correctly installed, Yet it still does not find the driver.
This is my code
public boolean checkLogin(String username, String password) {
try {
Connection myconObj;
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
URL databaseLocation = this.getClass().getResource("/com/vanstryp/database/MainUserData.accdb");
myconObj = DriverManager.getConnection("jdbc:ucanaccess:/" + databaseLocation);
ResultSet result;
Statement stmt = conn.createStatement();
String query = "select * from MainUserData";
result = stmt.executeQuery(query);
while (result.next()) {
String dbUsername = result.getString("Username");
String dbPassword = result.getString("Password");
System.out.println();
if (username.equalsIgnoreCase(dbUsername) && password.equals(dbPassword)) {
PrintWriter activeUser = new PrintWriter(new FileWriter("activeUser.db"));
activeUser.println(dbUsername);
activeUser.close();
return true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
This is the error message:
java.sql.SQLException: No suitable driver found for jdbc:ucanaccess:/file:/C:/Users/Jaco%20van%20Stryp/Dropbox/Fitness%20Perfect/build/classes/com/vanstryp/database/MainUserData.accdb