Using MySQL

From NeoWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 14:48, 24 August 2006 (edit)
Amayze ( | contribs)

← Previous diff
Revision as of 15:34, 24 August 2006 (edit) (undo)
Amayze ( | contribs)
(Detailed Installation for NeoOffice 2.0 Beta and above)
Next diff →
Line 51: Line 51:
# Ensure that no error message appears and that there is an entry in the white box. # Ensure that no error message appears and that there is an entry in the white box.
-====Detailed Installation for NeoOffice 2.0 Beta and above====+====Detailed Installation and Usage for NeoOffice 2.0 Beta and above====
-# If you haven't already, install NeoOffice/J (I am using v1.1, released 2005-06-22) and MySQL (I am using 4.1.13-standard).+=====Installation=====
-# Download Connector/J 3.0 from http://www.mysql.com and save it to the Desktop. (I downloaded v3.0.17, the tar.gz version).+# If you haven't already, install NeoOffice 2.0 (I am using v2.0 Aqua Beta 2 Patch 3, released 2006-08-24) and MySQL (I am using 5.0.24-standard).
 +# Download Connector/J 3.1 from http://www.mysql.com and save it to the Desktop. (I downloaded v3.1.13, the tar.gz version).
# Extract the Connector/J jar from the tar.gz archive. # Extract the Connector/J jar from the tar.gz archive.
-# Copy the .jar file to wherever you like (I chose <tt>~/lib</tt>).+# Copy the .jar file to wherever you like (Perhaps ~/Library/MySQL/ for personal use, or /Library/MySQL/ for all users of the Mac).
-# Launch NeoOffice/J.+# Launch NeoOffice.
-# From the '''NeoOffice/J''' menu, choose '''Preferences…'''.+# From the '''NeoOffice''' menu, choose '''Preferences…'''.
-# On the left is a tree of items. At the very top is "NeoOffice/J". Indented and underneath is a list of other items. Click on "Security".+# On the left is a tree of items. At the very top is "NeoOffice". Indented and underneath is a list of other items. Click on "Java".
-# This changes the panel on the right. At the bottom of the right panel is a "Java" section; click the "Browse" button in that section.+# This changes the panel on the right. At the right of this panel there are three buttons; click the bottom one marked "Class Path…".
-# This opens the "Select Archives" window. Make sure that there are no other Connector/J versions installed (e.g., 3.1) or they will make life messy. To remove them, click the jar file to select, then click Delete. Repeat as necessary. (Note: not all items here are necessarily Connector/J archives, use some caution).+# This opens the "Class Path" window. Make sure that there are no other Connector/J versions installed (e.g., 3.0) or they will make life messy. To remove them, click the jar file to select, then click Remove. Repeat as necessary. (Note: not all items here are necessarily Connector/J archives, use some caution).
-# Click the "Add" button.+# Click the "Add Archive…" button.
-# Browse to the directory where you installed the Connector/J 3.0 jar file (in step 4). Select the .jar file and click the "Open" button.+# Browse to the directory where you installed the Connector/J 3.1 jar file (in step 4). Select the .jar file and click the "Open" button.
# Click the "OK" button. # Click the "OK" button.
-# Exit NeoOffice/J.+# Exit NeoOffice.
-# Restart NeoOffice/J.+# Restart NeoOffice.
-# From the '''Tools''' menu, select '''Data Sources...'''; this opens the "Data Source Administration" window.+ 
-# Above the panel on the left is a button that says '''New Data Source'''. Click it.+You are now ready to use MySQL Databases with NeoOffice 2.0
-# In the right panel, select "MySQL" for "Database Type" and click "Apply".+ 
-# Click the "MySQL" tab at the top of the right panel.+=====Usage=====
-# In the "Type of connection" section, select the radio button next to "Use Connector/J3".+# From the '''File''' menu, select '''New''' and then '''Database''' from the hierarchical menu; this opens the Database Wizard.
-# Set the "MySQL JDBC driver class" to: <tt>com.mysql.jdbc.Driver</tt>+# In the right hand panel, select '''Connect to an existing databae''' and from the list below select "MySQL".
-# In the "General" section, change the non-grey part of the "Data source URL" to: <tt>localhost:3306/test</tt>+# Click '''Next >>>'''.
-# Set the user name and check the password box, if required.+# Select '''Connect using JDBC (Java Database Connectivity)''' and click '''Next >>>''' again.
-# Click the "Tables" tab at the top of the right panel.+# Enter the name of your MySQL database in the '''Name of database''' field (e.g. <tt>test</tt>).
-# Fill out your password if necessary.+# In the Server URL field enter <tt>localhost</tt>
-# Ensure that no error message appears and that there is an entry in the white box.+# The '''Port number''' should be left as the default <tt>3306</tt> unless you have modified your MySQL installation.
 +# The '''MySQL JDBC driver class:''' should also be left as the default <tt>com.mysql.jdbc.Driver</tt>.
 +# To check that the JDBC Driver is working click '''Test class'''; if all is well a dialogue should appear reporting that the driver was loaded correctly.
 +# Click '''Next >>>'''.
 +# Enter your MySQL User name in the field provided and select '''Password required''' if you have a password set for that user. N.B. If you do not select this option you will never be prompted for a password and all connections will fail if one was set.
 +# To check you have entered all the details correctly so far click '''Test connection'''.
 +# If you need to enter a password you will now be prompted to enter it, and optionally have it remembered until you quit NeoOffice.
 +# If all is well a dialogue will tell you so. If not go back to the previous screen and check the database name before returning to this screen and checking your username and password.
 +# If you don't want to register the database (so it doesn't appears in the ---) then select '''No, do not register the database'''
 +# Click '''Finish''' and choose a name and location to save the database.
 + 
 +You are now read to create queries and forms that use your MySQL database.
==== Configuration ==== ==== Configuration ====

Revision as of 15:34, 24 August 2006

While NeoOffice 1.2 Alpha, NeoOffice/J 1.1 and OpenOffice.org/X11 do not include a separate database component like Microsoft Access, it is possible to use either program to connect to existing MySQL databases and enter or manipulate data, including creating detailed forms and reports. This article contains information on installing, configuring, and using a MySQL database with NeoOffice or OpenOffice.org/X11.

If you do not have a MySQL database, you can create a simple database in NeoOffice or OpenOffice.org/X11—or even use a Calc table if your needs are very simple.

Contents

Enabling NeoOffice or OpenOffice.org/X11 to connect to MySQL databases

Using JDBC and Connector/J

Installation Overview

  • Download Connector/J 3.1 or later from the MySQL website.
    • The included README gives much information.
    • The most important keypoints are:
      • the class name of the JDBCdriver: com.mysql.jdbc.Driver
      • the URL format: jdbc:mysql://host.domain/database_name
    • For NeoOffice/J 1.1 and below, you will need a version of Connector/J (3.0) that supports Java 1.3.x, since that is the version of Java used in NeoOffice/J. NeoOffice 1.2 Alpha uses Java 1.4.2 and should use versions of Connector/J that support Java 1.4.2.
      • Note: Connector/J 3.1 and, presumably, later versions are not Java 1.3.x compatible.
  • The jar file location:
    • for OOo/X11: you can put it where you want. To let OOo know, you shoud go to "Tools->Options" menu item. Then in the "security" pane, there is a place to add directories to classpath. Click on browse and find your jar file.
    • for Neo: I had to put it in the <NeoOffice>/Contents/MacOS/classes folder to get it found. Didn't check with recent release if the previous classpath setting does work.
FYI. I just tried adding the MySQL jar file using the Security pane in the Tools->Options menu item Neo/J 1.1 Alpha 2. After adding the jar file in that pane and restarting Neo/J, I successfully connected to my MySQL database.
This works with Neo/J 1.1 final and newer. The former option is probably better for providing it to all users, whereas this is well suited for
There is also an attachment (.sxw) to OpenOffice.org Issue 13753 which contains screenshots and a different location for placing the Connector/J file.

Detailed Installation for NeoOffice/J 1.1 and below

Parts of this tutorial are out-of-date and incorrect for NeoOffice 1.2 Alpha and later

  1. If you haven't already, install NeoOffice/J (I am using v1.1, released 2005-06-22) and MySQL (I am using 4.1.13-standard).
  2. Download Connector/J 3.0 from http://www.mysql.com and save it to the Desktop. (I downloaded v3.0.17, the tar.gz version).
  3. Extract the Connector/J jar from the tar.gz archive.
  4. Copy the .jar file to wherever you like (I chose ~/lib).
  5. Launch NeoOffice/J.
  6. From the NeoOffice/J menu, choose Preferences….
  7. On the left is a tree of items. At the very top is "NeoOffice/J". Indented and underneath is a list of other items. Click on "Security".
  8. This changes the panel on the right. At the bottom of the right panel is a "Java" section; click the "Browse" button in that section.
  9. This opens the "Select Archives" window. Make sure that there are no other Connector/J versions installed (e.g., 3.1) or they will make life messy. To remove them, click the jar file to select, then click Delete. Repeat as necessary. (Note: not all items here are necessarily Connector/J archives, use some caution).
  10. Click the "Add" button.
  11. Browse to the directory where you installed the Connector/J 3.0 jar file (in step 4). Select the .jar file and click the "Open" button.
  12. Click the "OK" button.
  13. Exit NeoOffice/J.
  14. Restart NeoOffice/J.
  15. From the Tools menu, select Data Sources...; this opens the "Data Source Administration" window.
  16. Above the panel on the left is a button that says New Data Source. Click it.
  17. In the right panel, select "MySQL" for "Database Type" and click "Apply".
  18. Click the "MySQL" tab at the top of the right panel.
  19. In the "Type of connection" section, select the radio button next to "Use Connector/J3".
  20. Set the "MySQL JDBC driver class" to: com.mysql.jdbc.Driver
  21. In the "General" section, change the non-grey part of the "Data source URL" to: localhost:3306/test
  22. Set the user name and check the password box, if required.
  23. Click the "Tables" tab at the top of the right panel.
  24. Fill out your password if necessary.
  25. Ensure that no error message appears and that there is an entry in the white box.

Detailed Installation and Usage for NeoOffice 2.0 Beta and above

Installation
  1. If you haven't already, install NeoOffice 2.0 (I am using v2.0 Aqua Beta 2 Patch 3, released 2006-08-24) and MySQL (I am using 5.0.24-standard).
  2. Download Connector/J 3.1 from http://www.mysql.com and save it to the Desktop. (I downloaded v3.1.13, the tar.gz version).
  3. Extract the Connector/J jar from the tar.gz archive.
  4. Copy the .jar file to wherever you like (Perhaps ~/Library/MySQL/ for personal use, or /Library/MySQL/ for all users of the Mac).
  5. Launch NeoOffice.
  6. From the NeoOffice menu, choose Preferences….
  7. On the left is a tree of items. At the very top is "NeoOffice". Indented and underneath is a list of other items. Click on "Java".
  8. This changes the panel on the right. At the right of this panel there are three buttons; click the bottom one marked "Class Path…".
  9. This opens the "Class Path" window. Make sure that there are no other Connector/J versions installed (e.g., 3.0) or they will make life messy. To remove them, click the jar file to select, then click Remove. Repeat as necessary. (Note: not all items here are necessarily Connector/J archives, use some caution).
  10. Click the "Add Archive…" button.
  11. Browse to the directory where you installed the Connector/J 3.1 jar file (in step 4). Select the .jar file and click the "Open" button.
  12. Click the "OK" button.
  13. Exit NeoOffice.
  14. Restart NeoOffice.

You are now ready to use MySQL Databases with NeoOffice 2.0

Usage
  1. From the File menu, select New and then Database from the hierarchical menu; this opens the Database Wizard.
  2. In the right hand panel, select Connect to an existing databae and from the list below select "MySQL".
  3. Click Next >>>.
  4. Select Connect using JDBC (Java Database Connectivity) and click Next >>> again.
  5. Enter the name of your MySQL database in the Name of database field (e.g. test).
  6. In the Server URL field enter localhost
  7. The Port number should be left as the default 3306 unless you have modified your MySQL installation.
  8. The MySQL JDBC driver class: should also be left as the default com.mysql.jdbc.Driver.
  9. To check that the JDBC Driver is working click Test class; if all is well a dialogue should appear reporting that the driver was loaded correctly.
  10. Click Next >>>.
  11. Enter your MySQL User name in the field provided and select Password required if you have a password set for that user. N.B. If you do not select this option you will never be prompted for a password and all connections will fail if one was set.
  12. To check you have entered all the details correctly so far click Test connection.
  13. If you need to enter a password you will now be prompted to enter it, and optionally have it remembered until you quit NeoOffice.
  14. If all is well a dialogue will tell you so. If not go back to the previous screen and check the database name before returning to this screen and checking your username and password.
  15. If you don't want to register the database (so it doesn't appears in the ---) then select No, do not register the database
  16. Click Finish and choose a name and location to save the database.

You are now read to create queries and forms that use your MySQL database.

Configuration

With the above basic setup, the connection should work. Then you come to the fine tuning stuff: charset, etc...

There are additional pointers available in this thread on trinity on other MySQL configuration issues.

Using ODBC

mansky posts some steps for getting ODBC to work with MySQL and OpenOffice.org/X11 in this post on trinity; it also contains other OOo/MySQL pointers.

kervalen posts some steps for getting ODBC to work with MySQL and NeoOffice/J in this post on trinity.

More tips on ODBC in this thread.

This bug offers confirmation that NeoOffice 2.0 Alpha works with the ODBC driver from Actual Technologies.

Enabling NeoOffice to connect to an hsqldb database

This thread on trinity describes how to connect NeoOffice to an hsqldb database (hsqldb is used as the core of the Base component in OpenOffice.org 2.0).

Enabling NeoOffice to connect to an postgresql database

This bug has tips to help you connect to a postgresql database via JDBC using NeoOffice 2.0 Alpha.

Enabling NeoOffice to connect to a FileMaker Pro database

This post on trinity lists some general steps for connecting to a FileMaker Pro database.

If your database is simple and you want to convert it to NeoOffice Base, this post has some tips.

Using the Database with your NeoOffice Documents

Using the Database



NeoOffice/J 1.1 (in Italian) forms and queries
interacting with a MySQL database (108 KB)

information on how to use the database

Personal tools