All,

I can't seem to find anything on the web about how to connect to a LibreOffice database. I am currently using the following code to connect to a MS Access database and would like to know how to change it to work with LibreOffice.

String strConnect =
   "jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb, *.accdb);DBQ=C:\\db\\myDatabase.mdb;";

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(strConnect, "","");
if (null == con)
{
   System.out.println("Unable to connect to data source " + strConnect);
   return;
}

System.out.println("Successfully connected to database. Data source name:\n"
   + con.getMetaData().getURL() + "\n");

Thanks,
Bill

Recommended Answers

All 5 Replies

LibraOffice hasn't got any database, but does provide front-end suite, Base, that let you connect to different databases. You better check the features here

Thanks for the reply, Peter.

Here's the problem: I used LibreOffice Base to create a small, 3 table database for my business. The resulting file is in OpenDocument database format (.odb). I want to use Java to connect to and perform operations on that database.

Any suggestions? Anyone?

Thanks,
Bill

You should have mentioned that you want to connect with ODB file. It would have been different matter...

I should have been more specific. I'm pretty new to databases and LibreOffice, so I didn't know how to ask the question correctly.

-Bill

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.