Reputation: 61
I am trying to connect to a MS Access database using hsqldb in java. I added all the libraries I needed, but in the end I still get an exception: Exception in thread "main" java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: MESSAGES Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: MESSAGES
Code below:
Connection conn = null;
try {
Class.forName("org.hsqldb.jdbcDriver");
conn = DriverManager.getConnection("jdbc:hsqldb:D:/sms4.accdb", "sa", "");
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("select * from Messages"); //here is where I get the error
Upvotes: 1
Views: 2245
Reputation: 123549
HSQLDB cannot (as far as I know) open an Access database directly. You will need to use the UCanAccess JDBC driver. (It uses HSQLDB in the background, but your Java application never manipulates the HSQLDB "backing database" directly.)
For more information, see
Manipulating an Access database from Java without ODBC
Upvotes: 1