Connecting LO Base to an SQL DB

Hi All

Am trying to use Base with a MySQL Database and need help please.

OpSys - PCLinux 2012-6 KDE
LO - Version 3.6.2.2
My SQL is installed and running.
MyAdmin is installed (and I have created an empty Database with this)
MySQL connector - Downloaded 'mysql-connector-java-5.1.22'
Restarted LO then Started Base
Select 'Connect to existing Database' - MySQL
Accept 'Connect using JDBC'
Database Name - I entered 'path and file name'
Server - localhost (everything is on the local computer)
Port No - 3306
Driver Class - accept 'com.mysql.jdbc.Driver'
Test Class
*ERROR* - The JDBC driver could not be loaded.

The Wiki says /"You can find the correct class name in the documentation that came with the driver. MySQL java connector archive version 5.1.6 contains connector-j.pdf document with description in subdirectory docs. The class name is *com.mysql.jdbc.Driver* for version 5.1.6."/

But there are NO pdf files in the Folder!!

Can anyone confirm that my steps are correct and give me details on how to cure the error please?

Thanks a lot

IanW
Pretoria SA.

Hello Ian,
Just one question: the "native" MySQL-Connector should be included in
3.6.2. I had a lot of trouble in the past with it, but now it seems to be
the best choice of all the possible connectors (Native, ODBC, JDBC).
In any case, reading through your steps - I think that
- the database name should be the name of the database as defined in the
   create database statement of MySQL
- did you specify the correct path for the jdbc-connector?
Regards (from snowed-in Salzburg)
Heinz

Hi Heinz

Thanks for info....
So where is the "native" connector file?
Database name IS as specified in MySQL and is as saved - but I added the path as well (?)
The connector comes up automatically when you "register" it in Base.

(Sorry about your snow!! 25C here and sunny!!

IanW
Pretoria SA

Hi Ian,
To be honest - I am somewhat confused regarding the issue of "where is the
native connector"! It might be that going to extensions and then download/installing
the native connector (for OpenOffice) does the trick. On the other hand, I think
that it should come automatically with the newest versions of LO. The definition
of a natively connected MySQL database goes as follows:
- (1) connect to an existing database, then select "MySQL" from the drop-down
       list (JDBC is shown as the first item in that list! MySQL is third from
       bottom in my case)
- (2) on the next dialog box select "direct connection" (direkte Verbindung in
       German)
- (3) on the next dialog box specify the database name, server name, IP-address
       or localhost (127.0.0.1) and port (usually 3306) or else the socket file
       (possible in case of a local server)
- (4) then specify the username and whether a password has to be given on
       connection
- (5) then store the odb-file.
Hope this is of use to you...
Regards
H
P.S.: It's already getting warmer here again! This usually coincides with
       bad weather in Italy which in turn causes warm winds to come across
       the Alps

Thanks again Heinz

But I think we must have different versions of LO. Your 'Step 1' is OK for the first part, (and it's what I did before), but the second part here only gives me the options...

    o Connect using ODBC
    o Connect using JDBC

    So knowing the JDBC does not work I tried ODBC but that gives me....

        /Could not load the program library libodoc.so.1 or it is corrupted.
        The ODBC data source selection is not available./

        A search on my Hard Drive for 'libodoc' finds nothing and also
        Synaptic does not find it. I than looked under the Extension
        Manager in LO and found the 'Native Connector' written by my
        friend Alex Thurgood, (who seems to have vanished off eMail at
        the moment!!). But I see it is only a Pre-release for Ubuntu and
        I'm running PCLinuxOs - so will it work on my machine and if so
        do I just download it or what?

        IanW
        Pretoria SA.

Thanks Heinz

Well I even went off this morning looking at 'other' solutions for this and it seems to be - Use Base or go and learn PHP or Ruby or something like that!!

So I got into Base again and found an interesting fact - Base had _NOT_ stored the link in it's Driver Class!! After a couple of re-tries it now seems to have done that and I can now get past the 'Test Class' stage OK!!!

The next screen is 'Authentication' - I enter the User Name and select "Test Connection" and I get

    Communication Link Failure
    The last packet sent successfully to the Server was 0 milliseconds ago.
    The driver has not received any packets from the Server.

OK - Now I'm stuck again...... My Database (Schema) was called 'federals_Members.sql' when I first created it but last week I had to re-install my OpSys and to get it back into MyAdmin I had to import it and it's now there called 'Test'!! Neither of the above two file names make any difference to the error message.

Next the User Name - In My Admin it is 'root', when I set-up the Database I used 'Ianw' and my System login is 'Ianw' also. Again neither of these changes the error message.

To check I started MyAdmin and it connects fine with the Database and displays the table structure just fine.

So why wont Base connect to it???

Thanks

IanW

Hi :slight_smile:
Congrats on fixing that issue Ian!  Is there any chance of adding it somewhere in the Faq?
http://wiki.documentfoundation.org/Faq#Base
Regards from
Tom :slight_smile:

Ian Whitfield wrote:

Thanks Heinz

Well I even went off this morning looking at 'other' solutions for this and it seems to be - Use Base or go and learn PHP or Ruby or something like that!!

So I got into Base again and found an interesting fact - Base had _NOT_ stored the link in it's Driver Class!! After a couple of re-tries it now seems to have done that and I can now get past the 'Test Class' stage OK!!!

The next screen is 'Authentication' - I enter the User Name and select "Test Connection" and I get

   Communication Link Failure
   The last packet sent successfully to the Server was 0 milliseconds ago.
   The driver has not received any packets from the Server.

OK - Now I'm stuck again...... My Database (Schema) was called 'federals_Members.sql' when I first created it but last week I had to re-install my OpSys and to get it back into MyAdmin I had to import it and it's now there called 'Test'!! Neither of the above two file names make any difference to the error message.

Next the User Name - In My Admin it is 'root', when I set-up the Database I used 'Ianw' and my System login is 'Ianw' also. Again neither of these changes the error message.

To check I started MyAdmin and it connects fine with the Database and displays the table structure just fine.

So why wont Base connect to it???

Thanks

IanW

Ian,
Are you starting mysqld with "--skip-networking"?
If so, then remove it for "localhost" access. LO Base uses localhost to access mysqld and will give a failed to connect error if it can't connect via localhost. MyAdmin does not use localhost to connect, so it would work fine while Base will not.
Hope this helps.
Girvin Herr

I see you created a user name 'lanw' in My Admin. That is a good start. You also have to use My Admin to define what schema 'lanw' can access. Then you need to define what privileges 'lanw' should have for the databases in those schema.
      I can not be very specific because I no longer use MySQL 5.1. When I updated my Ubuntu OS, it installed MySQL 5.6. But I do know from personal experience that you can not access a database using a user name until you have entered what Schema it can access and what privileges it has for specific databases within the schema for which it has access.

--Dan

Ian,
Are you starting mysqld with "--skip-networking"?
If so, then remove it for "localhost" access. LO Base uses localhost to access mysqld and will give a failed to connect error if it can't connect via localhost. MyAdmin does not use localhost to connect, so it would work fine while Base will not.

No Gavin I am not!! MySQL starts automatically at Boot.

Dan wrote:

I see you created a user name 'lanw' in My Admin. That is a good start. You also have to use My Admin to define what schema 'lanw' can access. Then you need to define what privileges 'lanw' should have for the databases in those schema.

Thanks Dan
I started MyAdmin and found that the user 'Ianw' was no longer there - so I gave 'Any User' full privileges. This made no difference to my problem.

So then I went back to MyAdmin and created a New User 'Ianw' and give him full privileges and selected all Schemas.

Back to Base - still get 'Communications Failure'. Tried again this time selecting 'Password Needed' and this time it asked me for my Password but after that came back with the 'Communications Failure'

Any more ideas (I don't have much hair left!!!)

IanW
Pretoria RSA.

Ian Whitfield wrote:

Ian,
Are you starting mysqld with "--skip-networking"?
If so, then remove it for "localhost" access. LO Base uses localhost to access mysqld and will give a failed to connect error if it can't connect via localhost. MyAdmin does not use localhost to connect, so it would work fine while Base will not.

No Gavin I am not!! MySQL starts automatically at Boot.

<snip>

IanW
Pretoria RSA.

Ian,
If mysqld starts automatically at boot, then, like my Slackware system, you probably have a system script somewhere that starts mysqld. The --skip-networking may be in that script. In Slackware, it is "/etc/rc.d/rc.mysql" which has a macro definition in the beginning: "SKIP=--skip-networking". Simply commenting that line out with a # in column one enables network (localhost) access. You might check for something like that on your system.

In case it will help, here are the commands I use to configure MySQL and create my databases:

Thanks Girvin!!!

I had decided last night that I would completely remove phpMyAdmin today and try again and then your valuable info came into me this morning so I thought - This *IS* the way to go!!

If mysqld starts automatically at boot, then, like my Slackware system, you probably have a system script somewhere that starts mysqld. The --skip-networking may be in that script. In Slackware, it is "/etc/rc.d/rc.mysql" which has a macro definition in the beginning: "SKIP=--skip-networking". Simply commenting that line out with a # in column one enables network (localhost) access. You might check for something like that on your system.

I do _NOT_ have this file in my system. I did a search and found this ...

# Shorewall version 4 - MySQL Macro

UPDATE TO PREVIOUS POST

After opening MyAdmin and importing my 'empty' Table I find that Base now allowed me to go right through the connection process and asks me where I want to store the DB.

*BUT* When I go there and select it it opens and asks me for password and after that gives me the "Communication Failure" again.

!!!!!!

IanW
Pretoria RSA.

UPDATE TO PREVIOUS POST

After opening MyAdmin and importing my 'empty' Table I find that Base now

allowed me to go right through the connection process and asks me where I
want to store the DB.

*BUT* When I go there and select it it opens and asks me for password and

after that gives me the "Communication Failure" again.

!!!!!!

IanW
Pretoria RSA.

--
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems?

http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/

Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be

deleted

Are you able to connect to mysql via the command line?

Mas

Yes Mas, (as far as I understand it)

See below for terminal input/Output...

    [ian@localhost ~]$ mysql --user=root -p mysql
    Enter password:/[entered password]/
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 29
    Server version: 5.1.55 PCLinuxOS - MySQL Standard Edition (GPL)

IanW
Pretoria RSA

Ian,
It sounds like you are getting close, but there is still something blocking your access to the MySQL server (mysqld). All of these symptoms sure sound like the server is not looking at the localhost port.

Ian Whitfield wrote:
<snip>

I do _NOT_ have this file in my system. I did a search and found this ...

# Shorewall version 4 - MySQL Macro
#

<snip>
I am not familiar with your "Shorewall" system. I doubt this is related. There are many distributions of Linux and each one has its own way of configuring the processes. What I described is from Slackware Linux. Your's must be different, but I included the Slackware files in case they may point you in a good direction.
Here are some things to try:

   1. Look at "/etc/my.cfg", the mysqld configuration file. The mysqld
      server reads this file for configuration information when it boots
      up. If there is a "skip-networking" entry in there, comment it
      out with a "#" in column 1. Then restart mysqld or reboot. If
      you can't find the my.cfg file in /etc, then search for it
      elsewhere on your system.

   2. ping localhost
      You should get responses. (Ctrl-c will stop ping.) If you get
      something like "destination unreachable" or "unknown host", then
      localhost is not configured on your system. That could hang up
      Base. Linux installation should do this for you, but maybe your
      distro does not. If it isn't there, you could add it to "/etc/hosts":

          127.0.0.1 localhost

      Your system may need a reboot. You could try pinging localhost
      again after you add it to /etc/hosts to determine if you need to
      reboot.

I highly recommend reading the Section "Post-Installation Setup and Testing" in the MySQL Reference Manual. This document is a good source for configuring and testing MySQL. http://dev.mysql.com/doc/

<snip>

Started Base and selected my old DB to get to the Edit screen - BUT when I go there "Connection Type" is grayed out!!
Tried again selecting the new SQL DB but again the "Connection Type" is grayed out!!

I don't understand what you mean by "new SQL DB"? Did you try creating a new Base database connection with the wizard?

Is edit -> database -> Properties grayed out too?
You can set up the connection host and port in edit -> database -> Properties -> Additional Settings.

    Host name should be localhost.
    Port number should be 3306
    MySQL JDBC driver class should be com.mysql.jdbc.Driver if you are
    using JDBC.

For reference, I am using mysql-connector-java-5.0.7 with MySQL 5.0.67 and LO 3.5.3 . Not the latest, but it works.
Under edit -> database -> Properties -> "Advanced Properties", you can set up the database name and authentication:

    "Name of the MySQL database" is the name of the database you used in
    the CREATE DATABASE mysql statement.
    "User name" is the user name you used in the GRANT statement
    "Password required" should be checked if you set up a password in
    the GRANT statement.

If you made any changes from the above suggestions, can you now go through the Base database installation again without any problems?

Carried on with the Base page and put in all the details - 'Test Class' gives me "Succesful"
But 'Test Connection' still gives me the "Communication Failure"!!

This sounds like Base still can't talk to the server through localhost.

The var/lib/mysql Folder is there but is EMPTY(??)!!!!! (and has no permissions) and I can not delete it.

Are you looking at /var/lib/mysql as "root"? If not, it will look empty and if you try to enter the directory, err, folder, you should get a permission error if not root. There should at least be entries in the log from your use of mysql-secure-installation and mysql_install_db. Oops! I don't think I told you about "mysql_install_db"? If not, that's my bad. I am sorry I left it out. That needs to be run before anything else, including the mysqld server. Here is the correct sequence of configuration:

    (set up my.cfg)
    mysql_install_db --user=mysql #creates the databsae structures.
    mysqld_safe --user=mysql & #script to run the mysqld server.
    NOTE: sometimes called safe_mysqld
    mysql_secure_installation #removes insecure
    files/structures.
    mysql --user=root -p mysql #Allows you to create your
    databases, user names, permissions, etc.
    (set up Base)

This is documented in the Section "Post-Installation Setup and Testing" in the MySQL Reference Manual.
After running this sequence, the /var/lib/mysql directory should contain your database files, the error log, and other mysql internal files. Since these are sensitive files, only root can see/access them.

I know this is a lot to take in, but not being at your system means I have to throw out a lot of possibilities and suggestions.
Installing MySQL and getting Base working with it is not trivial, as you have seen. As far as I know, there is no one document to describe the process. Now add in all the other database server systems out there that Base can connect to and it really expands. That is why I keep notes on what my process is for the time I upgrade my Linux and have to do it all over again.
Hope this helps.
Girvin Herr

Thanks once again Girvin!!!!

1. Look at "/etc/my.cfg", the mysqld configuration file.

I have searched my whole drive and can not find a file with this name (??)
[even after running "mysql_install_db" as mentioned below - No such file on my system!!]

  2. ping localhost

[root@localhost ~]# ping localhost
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.localdomain (127.0.0.1): icmp_req=1 ttl=64 time=0.024 ms

I highly recommend reading the Section "Post-Installation Setup and Testing" in the MySQL Reference Manual. This document is a good source for configuring and testing MySQL. http://dev.mysql.com/doc/

Will go and look at this.

Started Base and selected my old DB to get to the Edit screen - BUT when I go there "Connection Type" is grayed out!!
Tried again selecting the new SQL DB but again the "Connection Type" is grayed out!!

I don't understand what you mean by "new SQL DB"? Did you try creating a new Base database connection with the wizard?

NO - I created my "new SQL Database" in MyAdmin and then imported all the fields from the previous time I did this.
But somehow the 'Connection Type' is now available to me BUT still gives me communication error!!!!

   Host name should be localhost. - *IT IS*
   Port number should be 3306 - *IT IS*
   MySQL JDBC driver class should be com.mysql.jdbc.Driver if you are using JDBC. - *IT IS*
For reference, I am using mysql-connector-java-5.0.7 with MySQL 5.0.67 and LO 3.5.3 . Not the latest, but it works.
Under edit -> database -> Properties -> "Advanced Properties", you can set up the database name and authentication:

I'm using mysql-connector-java-5.1.22, with MySQL 5.1.55, and LO 3.6.2.2 (Build ID: da8c1e6), and phpMyAdmin 3.5.2.

   "Name of the MySQL database" is the name of the database you used in the CREATE DATABASE mysql statement. *YES*
   "User name" is the user name you used in the GRANT statement - *IT IS*
   "Password required" should be checked if you set up a password in the GRANT statement. - *IT IS*

But 'Test Connection' still gives me the "Communication Failure"!!

This sounds like Base still can't talk to the server through localhost.

The var/lib/mysql Folder is there but is EMPTY(??)!!!!! (and has no permissions) and I can not delete it.

Are you looking at /var/lib/mysql as "root"? - *NO I WAS NOT!!*

Tried as 'root' and I can now see it - thanks for that!!

Oops! I don't think I told you about "mysql_install_db"? If not, that's my bad. I am sorry I left it out. That needs to be run before anything else, including the mysqld server. Here is the correct sequence of configuration:

   (set up my.cfg)
   mysql_install_db --user=mysql #creates the databsae structures.
   mysqld_safe --user=mysql & #script to run the mysqld server.
   NOTE: sometimes called safe_mysqld
   mysql_secure_installation #removes insecure
   files/structures.
   mysql --user=root -p mysql #Allows you to create your
   databases, user names, permissions, etc.

No - you did not tell me about this!! So I followed the instructions and got positive response all the way!!

(set up Base)

Went back to Base - BUT still get the dammed "Communication Link Failure"!!!!!

I'll go off and read the "Post Installation Guide" you mentioned and see if I can spot anything.

This is REALLY getting to be a total PITA - This is the 4th time I've tried to get this to work in the past 8 months or so. I really DON'T understand why it has to be such an involved and impossible way to do something!!!??

But I DO thank you Girvin (and others) who have been trying to help me.

Installing MySQL and getting Base working with it is not trivial, as you have seen. As far as I know, there is no one document to describe the process. Now add in all the other database server systems out there that Base can connect to and it really expands. That is why I keep notes on what my process is for the time I upgrade my Linux and have to do it all over again.

I also started a "Linux Set-up Document" when I started with the OpSys. I think the first one was one or one and half pages. 4 years on it is now over 20 pages of notes, methods, tips and tricks!! And *IF* I get this to work that will add a few more pages!!!

Thanks again and all the best

IanW
Pretoria RSA.

Ian,
The file is called "my.cnf" (NOT my.cfg!) on my system.
Regards
H

Thanks Guys!! (Girvin, Henirich, Dan, Mas and maybe others!!)

You have all added some pieces to the Jigsaw and I'm pleased to say......

*I now have Base working with a MySQL Database!!!! (at last!!)*

As Girvin would say "My Bad"!! I had been looking for the file 'my.cfg' when it should have been 'my.cnf'. This was the last missing piece, once I found it and found the "skip-networking" line inside it and commented it out everything worked fine.

So once again guys - thanks for sticking with me - awesome support and I do appreciate it!!

Now the fun starts - I have already designed my Form yesterday but now need to puzzle out how to get all my data out of the old DB into the new SQL DB. And then re-write all my Queries and reports.

Greatly appreciated - regards from South Africa

IanW
Pretoria RSA.

If you can get your data out of the old database as a csv file it is real easy to load into MySQL.
You can use the command line MySQL command or if you install webmin it makes database admin easy.
Steve