个人工具

UbuntuHelp:UsingJavaDatabaseConnectivityAndOpenOffice

来自Ubuntu中文

跳转至: 导航, 搜索

Introduction

This document explains how to use OpenOffice.org to edit MySQL Database files using JDBC Connectivity

Setting up JDBC

See Installing JDBC for MySQL 5.0 for instructions on how to set up MySQL and JDBC on Ubuntu.

Connecting via OpenOffice

Start up Openoffice.org Database, and click on "Connect to an existing Database" on the Database Wizard. The connection type should already be selected as "JDBC" Click "Next"

Setting up the Connection

The DataSource URL states where the Database is

jdbc:mysql://127.0.0.1/emotherearth

This is four parts

  1. jdbc: specifies that we are going to access the database using Java Database Connectivity. You don't need to type this as it is already there.
  2. mysql: specifies that we are going to connect to a mysql database
  3. 127.0.0.1 specifies the machine the server is on - this is our own machine "localhost"
  4. emotherearth is the name of the MySQL Database we are going to connect to.

The JDBC Driver Class is the Java packaged file that helps us connect to MySQL this should be

com.mysql.jdbc.Driver

Click on "Test Class" and you should get a message that the driver has successfully loaded. If not, check the JDBC installation, especially CLASSPATH. Click "Next"

User information

When you set up your MySQL server, you set up a user name and password. This is not the same as your ubuntu name and password - it belongs to MySQL. You can make the same but it isn't required. Enter the MySQL password and check the Password required box Click on the "Test Connection" button, and enter the password. It should now successfully connect to the database. If not, check your username, password and the Datasource URL. Click "Next"

Registering the Database

I leave "Register the Database for me" as this allows the 'connection' to be saved. If you click "Next" again you will be shown a Save dialog to save the connection details, then the main OpenOffice.Org Database page will appear. The first time you do something it will ask you to type the password, but other than that it will remember it until you leave Openoffice.

The next time

The next time you want to use the file (e.g. after closing OpenOffice) you simply open the file you saved in "Registering the Database". You will need to type the password in, but nothing else.