Is Java JDBC compatible with the LibreOffice HSQL ?

I created a HSQLDB file using LibreOffice Base 4.4.7.2. In the Tool>Option>Advanced, the JRE class path is set to my JDK 1.7.0_80 & it is selected. The database contains a table named TABLE1.

In the Eclipse IDE, I added the hsqldb.jar (version 2.3.4 downloaded from hsql.org) to “Referenced Libraries” under Java Build Path. Here are codes to access the file with JDBC:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public static void main(String[] args) {
       Connection conn = null;
        try {
            Class.forName("org.hsqldb.jdbc.JDBCDriver");                
            String url = "jdbc:hsqldb:file:C:/mydb.odb;default_schema=true";
            conn = DriverManager.getConnection(url, "SA", "");

        System.out.println("Connection to Hypersql has been established.");

        Statement stmt = conn.createStatement();

        ResultSet rs = stmt.executeQuery("SELECT * FROM TABLE1");
        rs.close();            

    } catch (SQLException e) {
        System.out.println(e.getMessage());
    } finally {
        try {
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
    }
}

When it run until the executeQuery, the SQLException “user lacks privilege or object not found: TABLE1” was thrown. Whats wrong?

Hello,

I hardly ever use Java code, but it appears your connection is to a Base file (mydb.odb). The connection needs to be to the database itself - possibly in a sub directory as mydb (seems like a split DB default name).

Check this thread:

Thanks for antropoide comment.
Kind of disappointed that LO doesn’t support java. Now I switched to another tool (DBeaver) to create the database instead.