LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   OpenOffice 3.0.1, JDBC, MySQL and Base (https://www.linuxquestions.org/questions/slackware-14/openoffice-3-0-1-jdbc-mysql-and-base-707468/)

tronayne 02-25-2009 11:06 AM

OpenOffice 3.0.1, JDBC, MySQL and Base
 
Has anyone successfully gotten OpenOffice 3.0.1 connected to an existing MySQL data base (and, gee, how'd you do it)? This is a full installation of Slackware 12.2 (with all the patches applied).

I have installed mysql-connector-java-5.1.7-bin.jar and it reports that it loads successfully, the CLASSPATH environment variable is set, the data base exists and I can access it and do whatever I want with the command line interface. I've read everything I can find about OpenOffice, MySQL and Base and followed step-by-step with not luck.

Any hints?

broxtor 02-26-2009 04:30 AM

I didn't have much luck with the jdbc driver either. I installed the ODBC driver instead and that works without a problem.

tronayne 02-26-2009 07:38 AM

Thanks for the information -- so, I went to http://www.slacky.eu, got the package, built and installed it and... uh, I'm a little lost (even after reading all the unixodbc stuff). I'd appreciate a little nudge in the right direction if you could, with thanks.

broxtor 02-26-2009 08:37 AM

There's a configuration file somewhere in /etc/ that you have to modify. That file should contain the information for connecting to the database. I'm not sure what the file is called. I don't have access to my own linux computer at the moment, so I can't look it up. When I get home this evening I will have a look and post some more information here.

tronayne 02-26-2009 01:56 PM

If you can, I'd really appreciate seeing what your /etc/odbc.ini and /etc/odbcinst.ini files look like; trying to follow the MySQL documentation and the unixODBC documentation has gotten me, pretty much, completely confused. I have installed mysql-connector-odbc-3.51.27-linux-x86-32bit.tar.gz so the MySQL libraries are there but after that I'm lost. Thanks again for your help.

arubin 02-27-2009 03:17 AM

Not sure if this is at all relevant. I have done some programming using java to access the MySql database. All it involves is having the mysql-connector.jar file in jre/lib/ext. Never tried OpenOffice with it though

broxtor 02-27-2009 01:00 PM

Hi.
I'm a bit later with my response then I said I would be, but I was rather busy yesterday. But here it is:

My odbcinst.ini is entirely empty.
My odbc.ini contains the following:
Code:

[ODBC Data Sources]
odbcname    = MyODBC 3.51 Driver DSN

[DatabaseName]
Driver      = /usr/lib/odbc/libmyodbc.so
Description  = MyODBC 3.51 Driver DSN
SERVER      = 192.168.1.100
PORT        = 3306
USER        = dbusername
Password    = dbpassword
Database    = dbname
OPTION      = 3
SOCKET      =

change dbusername, dbpassword, dbname in your mysql username, password and database you want to connect to.

@arubin
I gave your hint a try, but it still doesn't work with the jdbc driver. The driver does load according OOo, but when I try to test the connection I get an SQL syntax error.

BCarey 02-27-2009 01:48 PM

There is a configuration tool called ODBCConfig included with unixODBC.

Brian

tronayne 02-27-2009 02:32 PM

Hi, Broxtor,

Thank you for the listing of odbc.ini; that goes a ways toward figuring out just what's what with this software (never messed with ODBC before).

By the way, the ODBCConfig utility will not work with Slackware 12.2 and qt-3.3.8b-i486-2 (the 12.2 distribution version); the files odbcinstQ.exp and SQLManageDataSources.cpp in the odbcinstQ directory in version unixodbc-2.2.14-i486-1 (the current version) must be edited or replaced with new ones (this per Nick Gorham, the developer) and the package rebuilt. I did this with src2pkg and the ODBCConfig utility now works (it was reporting /usr/lib/libodbcinstQ.so: undefined symbol ODBCManageDataSources).

The changes, are (odbcinstQ.exp)
Code:

QTSQLManageDataSources
QTSQLCreateDataSources
ODBCManageDataSources
ODBCCreateDataSource

and (SQLManageDataSources.cpp)
Code:

/**************************************************
 * SQLManageDataSources
 *
 **************************************************
 *
 * This library should only be used by odbcinst!
 *
 * This code was created by Peter Harvey @ CodeByDesign.
 * Released under LGPL 26.OCT.01
 *
 * Contributions from...
 * -----------------------------------------------
 * Peter Harvey                - pharvey@codebydesign.com
 * Nick Gorham      - nick@easysoft.com
 **************************************************/

#include <odbcinstext.h>

#ifdef QT_V4LAYOUT
#define QT3_SUPPORT
#include <Qt/qdir.h>
#include <Qt/qwidget.h>
#include <Qt/qnamespace.h>
#else
#include <qdir.h>
#include <qwidget.h>
#if QT_VERSION<300
#include <qnamespace.h>
#endif
#endif

#include "CODBCConfig.h"
#include "CODBCCreate.h"

static BOOL SQLManage( HWND hWnd )
{
    //
    // This will allow us to call this from a non QT app
    //
    if ( !qApp )
    {
        int argc = 1;
        char *argv[] = { "odbcinstQ", NULL };

        static QApplication a( argc, argv );
    }

    QWidget *pwidget = (QWidget*)hWnd;

#if QT_VERSION<300
        CODBCConfig odbcconfig( pwidget, "ODBCConfig", Qt::WType_Modal );
#else
        CODBCConfig odbcconfig( pwidget, "ODBCConfig", Qt::WType_Dialog | Qt::WShowModal );
#endif
        odbcconfig.exec();

    return true;
}

static BOOL SQLCreate( HWND hWnd, LPCSTR dsn )
{
    //
    // This will allow us to call this from a non QT app
    //
    if ( !qApp )
    {
        int argc = 1;
        char *argv[] = { "odbcinstQ", NULL };

        static QApplication a( argc, argv );
    }

    QWidget *pwidget = (QWidget*)hWnd;

#if QT_VERSION<300
        CODBCCreate odbccreate( pwidget, "ODBCCreate" );
#else
        CODBCCreate odbccreate( pwidget, "ODBCCreate" );
#endif
        odbccreate.setDsn( dsn );
       
        odbccreate.exec();

    return odbccreate.getRetCode();
}


#ifdef __cplusplus
extern "C" {
#endif

BOOL QTSQLManageDataSources( HWND hWnd )
{
    return SQLManage( hWnd );
}

BOOL QTSQLCreateDataSources( HWND hWnd, LPCSTR lpszDS )
{
    return SQLCreate( hWnd, lpszDS );
}

BOOL ODBCManageDataSources( HWND hWnd )
{
    return SQLManage( hWnd );
}

BOOL ODBCCreateDataSource( HWND hWnd, LPCSTR lpszDS )
{
    return SQLCreate( hWnd, lpszDS );
}

#ifdef __cplusplus
};
#endif

I believe that Nick will make the corrections to the release soon.

Thanks again!

Thomas

arubin 02-28-2009 02:31 PM

Well I have now got home to my PC and successfully connected with OpenOffice Base to a MySql database without touching any ini file

arubin 02-28-2009 02:38 PM

Step by step procedure using the database wizard:

Choose connect to an existing database

Select MySql

Next.

Select using JDBC
Next

Enter name of database
For server URL enter a space
Next

Enter username. Tick password required

Next

Choose whatever
Finish

Enter the password I use for MySql

tronayne 02-28-2009 04:33 PM

Thank you for the information; however, well, it doesn't work (it fails with "communications link failure") though I can connect with ODBC drivers with no problem.

I'm using mysql-connector-java-5.1.7-bin.jar with openoffice.org-3.0.1_en_US-i586-1_rlw (the one from Robby Workman).

I have tried localhost, a space, the address, "me"@localhost and every combination of ingredients I can think of with the same result. Sigh.

Thanks for your help.

arubin 02-28-2009 05:53 PM

My set up is Slackware Open Office from slackbuilds with jdk-6u11-i586-1.tgz off slackware extras installed and mysql-connector-java-3.1.12-bin.jar in lib/ext/ (not /jre/lib/ext as I wrote earlier. I don't know if that makes a diiference)

arubin 02-28-2009 05:57 PM

Indeed it does make a difference. The connector must be in /usr/lib/java/lib/ext, not as previously stated

arubin 02-28-2009 06:21 PM

I have just written a short java program which should test whether your java mysql connection is working. I can email it to you if you want.


All times are GMT -5. The time now is 03:47 PM.