Skip to main content

The trouble of getting APEX on MySQL to work...

In theory it should be so easy...running an APEX application on an Oracle instance with database links to MySQL for retrieving and modifying data. In theory that is, because in practice it is somewhat more cumbersome. I finally got there, but it took some steps  - and patience...

I started off with the steps provided from a couple of websites. Like these from Birijan, from Pythian, from WebAJ and from Easysoft. They´re all not the most recent ones, so I downloaded the latest versions of MySQL (5.1.51), MySQL Connector for ODBC (5.1.7) and unixODBC (2.3.0) and installed this stuff on top of the Oracle Developer Days Virtual Machine. Following the steps provided on the sites earlier mentioned I had a MySQL database with a demo table within minutes. So far so good!

After changing the odbcinst.ini, odbc.ini, tlistener.ora, tnsnames.ora and the initmysql.ora (in $ORACLE_HOME/hs/admin) file I fired up SQL*Plus and created a databaselink using 
create database link mysql
  connect to "demo"
  identified by "demo"
  using 'mysql';
So I expected a nice return set when I entered
select * from "employees"@mysql;
But instead of a list of employees I got this (very unclear) message:
ERROR at line 1:
ORA-28500: connection from ORACLE to a 
non-Oracle system returned this message:
So I Googled around, tried this and that, traced everything traceable. But still couldn't get any other result than the ORA-28500. So I turned to the forum for help, which resulted in this thread. In the last post you can see what the (simple) solution was: in the initmysql.ora (or whatever that file is called), I had a line for the language/region/characterset setting and there was a very tiny typo ...
should be
So from that moment on, I could enter a SQL statement in SQL*Plus and retrieve data from my MySQL database! But the happiness didn't last that long ;-(
Over and over and whatever I tried, I only retrieved just one row from my employees table - the first one according to the ordering of the result set. And sometimes even I just got one - the first - column back, and the other columns where just "gone"....

So, again, I called to the Oracle Forums to the rescue, which resulted in this thread. Again, a lot of tracing and after some time it seemed to be a problem in the version of the MySQL ODBC Connnector, because version 5.1.7 didn't work (and 5.1.0 had the same problem), while 5.1.5 did work. So I deinstalled my current version and reinstalled the previous GA version: 3.51.27. And from that moment on it worked flawlessly! I could query, insert, update and delete records in my MySQL database from Oracle without a hitch.

The last step - using an APEX application to do the data manipulation - is well written by Ilmar Kerm in this blog post, including some code to implement optimistic locking and to overcome the ORA-02047 error. And now - finally - I got an APEX application running on MySQL (in fact, it stills runs on Oracle, but uses MySQL data of course).

So after all you can do it in an hour or two:
- if you don't make any stupid typos and
- if you're "lucky" enough to use (or get) the working drivers immediately!

Popular posts from this blog

Dockerize your APEX development environment

Nowadays Docker is everywhere. It is one of the main components of Continuous Integration / Continuous Development environments. That alone indicates Docker has to be seen more as a Software Delivery Platform than as a replacement of a virtual machine.

However ...

If you are running an Oracle database using Docker on your local machine to develop some APEX application, you will probably not move that container is a whole to test and production environments. Because in that case you would not only deliver a new APEX application to the production environment - which is a good thing - but also overwrite the data in production with the data from your development environment. And that won't make your users very excited.
So in this set up you will be using Docker as a replacement of a Virtual Machine and not as a Delivery Platform.
And that's exactly the way Martin is using it as he described in this recent blog post. It is an ideal way to get up and running with an Oracle database …

Refresh selected row(s) in an Interactive Grid

In my previous post I blogged about pushing changed rows from the dabatase into an Interactive Grid. The use case I'll cover right here is probably more common - and therefore more useful!

Until we had the IG, we showed the data in a report (Interactive or Classic). Changes to the data where made by popping up a form page, making changes, saving and refreshing the report upon closing the dialog. Or by clicking an icon / button / link in your report that makes some changes to the data (like changing a status) and ... refresh the report.  That all works fine, but the downsides are: The whole dataset is returned from the server to the client - again and again. And if your pagination size is large, that does lead to more and more network traffic, more interpretation by the browser and more waiting time for the end user.The "current record" might be out of focus after the refresh, especially by larger pagination sizes, as the first rows will be shown. Or (even worse) while you…

Using multiple Authentication Schemes for your APEX application

Recently someone asked me how he could implement multiple authentication schemes for his APEX application. He would like to use (some kind of) Single Sign-on authentication and - as an alternative - an Application Express Authentication. The problem is ... you can only define one Authentication Scheme being "Current" for an application! So how can we solve this issue?

First, we need te be aware that multiple applications can share their authentication by using the same cookie. Thus if you specify "MYCOOKIE" as the Cookie Name in Application A as well as in Application B, you can switch from A to B and back without the need of logging in again. It doesn't matter what Authentication Scheme Type you are using!

Knowing this, we are halfway our solution. We need two Applications. One - the "real" application - using the Application Express Authentication, let's name this one "LAUNCHPAD". And another one using the Single Sign-on Authentication…