Chillax
Chillax

Reputation: 4708

Not able to connect to OpenOffice Base - User lacks privilege or object not found Exception

I am trying to connect to an OpenOffice Base database from Java and execute a query, and have not been able to.

These are the steps I followed:

1) Created a Database 'TestDB.odb' in OpenOffice, and a table 'Movies' with columns (ID, Name, Director)

2) Downloaded hsqldb jar file and inclued in project build path

3) Used the following code to connect to it:

String file_name_prefix = "C:/Documents and Settings/327701/My Documents/TestDB.odb";
Connection con = null;
Class.forName("org.hsqldb.jdbcDriver"); 
con = DriverManager.getConnection("jdbc:hsqldb:file:" + file_name_prefix, "sa","");
Statement statement = con.createStatement();
String query1 = "SELECT * FROM \"Movies\"";
ResultSet rs = statement.executeQuery(query1);

Althoug I'm able to connect to the Database, it throws the following exception on trying to execute the query:

org.hsqldb.HsqlException: user lacks privilege or object not found: Movies

Tried googling, but have not been able to resolve my problem. I'm stuck and it would be great if someone could guide me on how to fix this issue?

Upvotes: 0

Views: 851

Answers (2)

agodinhost
agodinhost

Reputation: 391

OLD thread.

I lost 2 days of my life until I changed the property:

spring.jpa.properties.hibernate.globally_quoted_identifiers = false

I was using mysql before and then I changed to hsqldb in order to run some tests. I kinda copied and pasted this property without looking and then you know - Murphy's law ...

I hope it helps.

Upvotes: 0

fredt
fredt

Reputation: 24352

You cannot connect to an .odb database. The database you have connected to is in fact a separeate set of files with names such as TestDB.odb.script, etc.

Check http://user.services.openoffice.org/en/forum/viewtopic.php?f=83&t=17567 on how to use an HSQLDB database externally from OOo in server mode. You can connect to such databases with the HSQLDB jar.

Upvotes: 1

Related Questions