I am trying to access a database that is stored in the classpath. I have installed ucanaccess 3.0.0 and all the required .jars.
My project hierarchy:
:
Here is the code I have so far:
public void login()
{
Connection conn;
try {
conn = DriverManager.getConnection("jdbc:ucanaccess:/database/theDB.accdb");
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("SELECT Student_Number FROM User");
while (rs.next()) {
System.out.println(rs.getString(1));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
It's a simple login screen and I'm just testing the connection to the databse on a button click. I understand that referencing an absolute file-path is not good, so I thought having the file in the classpath would be better.
I am getting the error
No suitable driver found for jdbc:ucanaccess:file:/C:/Users/Gandalf/workspace/FubbleApp/bin/database/theDB.accdb
So I think it must be the "/database/theDB.accdb" but I am not sure how to fix this issue.
Any help is appreciated. Thanks in advance