OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to connect to MySQL?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
xarmin
Newbie
Newbie


Joined: 18 Apr 2006
Posts: 4
Location: Japan

PostPosted: Tue Apr 18, 2006 11:42 pm    Post subject: How to connect to MySQL? Reply with quote

I'm new to OOo and have minimally played around with MySQL before.
Needing to set up a data base for good for the first time, I decided to install OpenOffice (Base) as a front end and MySQL as the DB engine on a Windows XP box.

I installed MySQL and the ODBC package first, then OpenOffice, bundled with Java.
MySQL installed fine, as I issue SQL commands, but don't know how to test whether ODBC is working.

From Writer, I want to click Tools -> Data Source, which, according to the docs, should open the Data Source Administration window, which has a New Data Source button. However, there is no Data Source entry in my Tools menue at all!

Is there another way to open the Data Source Administration window, or why would it be hiding?

Could anyone point me to relevant, up-to-date and easy to understand instructions how to connect to MySQL - preferrably via ODBC, or also JDBC?

Thanks a lot! - Cucumber
Back to top
View user's profile Send private message Visit poster's website
wahur
Power User
Power User


Joined: 22 Sep 2004
Posts: 62
Location: Tallinn, Estonia

PostPosted: Wed Apr 19, 2006 12:17 am    Post subject: Reply with quote

xarmin! You seem to be doing it OOo1.x way. Which version you have?
In case of OOo2.0 you set up connection using Base, register the resulting database and then it is possible to connect from other apps.

Wahur
Back to top
View user's profile Send private message
kleiner
Newbie
Newbie


Joined: 19 Apr 2006
Posts: 1

PostPosted: Wed Apr 19, 2006 1:24 am    Post subject: Re: How to connect to MySQL? Reply with quote

xarmin wrote:
I'm new to OOo and have minimally played around with MySQL before.
Needing to set up a data base for good for the first time, I decided to install OpenOffice (Base) as a front end and MySQL as the DB engine on a Windows XP box.

I installed MySQL and the ODBC package first, then OpenOffice, bundled with Java.
MySQL installed fine, as I issue SQL commands, but don't know how to test whether ODBC is working.

From Writer, I want to click Tools -> Data Source, which, according to the docs, should open the Data Source Administration window, which has a New Data Source button. However, there is no Data Source entry in my Tools menue at all!

Is there another way to open the Data Source Administration window, or why would it be hiding?

Could anyone point me to relevant, up-to-date and easy to understand instructions how to connect to MySQL - preferrably via ODBC, or also JDBC?

Thanks a lot! - Cucumber


hi,

i worked with Openoffice 2.0.1 and MySql - it works fine. I connected with JDBC.
After I installed Openoffice 2.0.2 it doesn't work anymore, so I had to go back to 2.0.1.

You wrote your MySql works, create an empty database. So I explain what i have done (Maybe some words are different to your installation, cause i use the german OO translation):
First : You have to install the JDBC driver from MySqQL, just copy the file mysql-connector-java-5.0.0-beta-bin.jar t to your JAVA Directory lib/ext

Under extras->options choose OpenOffice.org->Java and set the classpath to the copied file including the filename. Restart Openoffice.
Then follow http://searchopensource.techtarget.com/tip/1,289483,sid39_gci1148271,00.html
do not create an database, connect to to an existing database. In the drop down box choose Mysql. Next Window connect over JDBC. Next window name of the database, Hostname (localhost). The driverclass should be "com.mysql.jdbc.Driver"
Next window username and password if needed. in the last window you can accept all things. Last give a name for the connection.
From calc (eg) choose view datasource (F4) there you can use youre database.
I hope i could help you

kleiner
Back to top
View user's profile Send private message
xarmin
Newbie
Newbie


Joined: 18 Apr 2006
Posts: 4
Location: Japan

PostPosted: Wed Apr 19, 2006 6:57 pm    Post subject: Thanks! JDBC and ODBC both worked! Howto for the record. Reply with quote

Thanks a lot, I got OOo to talk to MySQL through JDBC. First, let me put down for the records what I did:

Mysql replied to SELECT VERSION (); with 5.0.20-nt. After unzipping the JDBC connector downloaded from mysql.com, I copied the jar file to the following location:
C:\Program Files\Java\jre1.5.0_06\lib\ext\mysql-connector-java-3.1.12-bin.jar
In MySQL, just to have something to find, I created a table "pets" in a database "test":
USE test;
or if it doesn't exist already, first:
CREATE DATABASE test;
then:
CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), birth DATE);
(See http://dev.mysql.com/doc/refman/5.0/en/database-use.html)

Next, following the above advice, I uninstalled OOo 2.0.2 and installed OOo 2.0.1.
Then I double-clicked C:\Program Files\OpenOffice.org 2.0\program\sbase.exe to start Base, which brought up the Data Baze Wizard asking me whether I want to create a new DB, open an existing DB file or connect to an existing DB file. Choose connect to a n existing DB and pick MySQL from the list. In the next window, I chose JDBC, then entered:

JDBC
Name of DB: test
Server ULR: localhost
Port No: 3306 (Which is MySQL's default setting)
JDBC driver class also default: com.mysql.jdbc.Driver
The TEST button loaded the driver successfully.

In the next window, I entered login root , clicked test connection -> connection ok upon entering password. Final window, click "yes, register" and "open DB for editing", and there went Base with my PET table and the correct entry fields. The test DB could also be accessed from Writer by pressing the F4 button. Wonderful!

ODBC

To get the records complete, I played around with ODBC and got it to work as follows:
In the Basse Data Baze Wizard, I chose:
Connect to existing DB, MySQL (as above)
then ODBC instead of JDBC.
That asks me for the Name of the ODBC data source on my system.
Pressing the Browse button opens a Data Source window, in which I pressed the Organize button, which opens the ODBC Data Souce Adminstrator window. The add button brings up the Data Source Creator window, which fortunately contained the MySQL ODBC 3.51 Driver, which I double-clicked.
This finally opened the Connector/ODBC window (with a MySQL logo Smile, in which I entered:
Data Source Name: MySQL-DB1
Description: ODBC connection
Server: localhost
User: root
Password: *****
Data Base: test2
(I had created this DB new in MySQL beforehand)

Everything worked fine and test2 loaded into Base as above, and I created a table "persons" with fields firstname, lastname, age, and Base added an ID index column to it automatically while saving.
Back in MySQL, I could in fact see and manipulate the new table and contents:
Code:
use test2;
select * from persons;
update persons set firstname='John' where lastname='Miller';
select * from persons;

and when loaded into Writer with F4, the table showed correctly that Mr. Miller's fist name is John. So, OOo and MySQL are talking to each-other in perfect harmony!

Thanks a lot for the help. I'll play just a bit more and sum it all up in a HowTo page on my website, say
http://www.biojapan.de/rump/armin/ooomysql.html
over the next few days. I'll drop a line to the forum when done.
(If you have comments to include in a HowTo summary page, please go ahead!)
Back to top
View user's profile Send private message Visit poster's website
wahur
Power User
Power User


Joined: 22 Sep 2004
Posts: 62
Location: Tallinn, Estonia

PostPosted: Wed Apr 19, 2006 10:27 pm    Post subject: Reply with quote

To my experience, downgrading to 2.0.1 is probably a mistake. Database stuff has been getting improved significantly with every new minor version. I was testing OOo2.0.2-MySQL5.0.18 combo for a while and it did work just fine - only lack of certain features has turned me elsewhere.

Wahur
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group