Other ways to access Derby and view data
Discover alternative ways of accessing Derby and viewing your data.
Alternative methods for accessing Derby from OpenOffice.org
Throughout this tutorial, you've been using the localhost network server method to access Derby. But two other methods work as well. The first is a variation on the network server. By replacing localhost with the Domain Name System (DNS) entry for the computer, you can access the Derby database from other computers. (I wouldn't recommend doing this unless you implement a strong authorization/authentication system for your database.) Using this method, you can centrally locate the database along with the OpenOffice.org Base and Calc files necessary to access the database.
However, if, as in this tutorial, you're working with relatively static data and performing analysis, it's best to run Derby in embedded mode. Doing so allows you to fully integrate Derby with OpenOffice.org and releases you from the requirement of having the network server running at all times. Although only one JVM can access the database at a time when running in embedded mode, the good news is that OpenOffice.org uses only one JVM during execution, so you can still access the database from multiple documents and applications. For your purposes, the gains in portability and ease of use far outweigh the disadvantages.
Use OpenOffice.org Base in embedded mode
To switch OpenOffice.org Base to use the database in embedded mode, complete these steps:
- Start OpenOffice.org Base.
- Click Edit > Database > Properties.
- Replace the localhost and port in the connection string with the location of the file (in your case, C:/databases/WCNDerby01).
- Change the driver (located in the Derby.jar file you added to the
OpenOffice.org
classpathvariable earlier) toorg.apache.derby.jdbc.EmbeddedDriver. Your entry should look like that shown in Figure 26.
Figure 26. Changing to embedded Derby
View data from Microsoft Excel
If you're using Excel, Derby can fit in with your plans. Before you can connect to Derby from Excel, you must install several components. (See Resources for details.) After following the instructions for setting up Derby Open Database Connectivity (ODBC), you can import the data directly into Excel. To do so, complete these steps:
- Using a blank workbook, click Data > Import External Data > New Database Query.
- In the Choose Data Source window, choose the ODBC DSN (that is, oocalcdb) that you created earlier, as shown in Figure 27.
Figure 27. Choosing the ODBC DSN
- Choose the view you created earlier, and select to retrieve all the columns, as shown in Figure 28.
Figure 28. Choosing the view
The result is returned directly to a worksheet, where you can use Excel tools to analyze it. Figure 29 shows the data in Excel.
Figure 29. Viewing the data in Excel
Now, you're free to use the many powerful analysis tools available in Excel. (Note that embedded mode is not available to you when accessing the data from Excel.)

