Ask Your Question
0

Is Java JDBC compatible with the LibreOffice HSQL ?

asked 2018-09-11 12:46:26 +0100

len gravatar image

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?

edit retag flag offensive close merge delete

Comments

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).

Ratslinger gravatar imageRatslinger ( 2018-09-11 16:26:07 +0100 )edit
antropoide gravatar imageantropoide ( 2018-09-12 11:50:31 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2018-09-14 05:42:23 +0100

len gravatar image

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.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-09-11 12:46:26 +0100

Seen: 37 times

Last updated: Sep 14