Open Database Connectivity in Jaguar
Pages: 1, 2
Location, Location, and Type
There are two ways to test an ODBC connection: the first is to use the odbctest command line application (comes with Jaguar and is in /usr/bin), the second is to use the test feature of iODBC's administrator. I would recommend testing with both applications before making a definitive decision as to whether or not your driver or setup works. I have had experiences with various drivers where one works and the other does not but an ODBC connection can be established with the driver.
I started by testing from iODBC's administrator. I choose my DSN from the User DSN tab, crossed my fingers and clicked test. And it didn't work. I got back two messages:
- IM003 [iODBC][Driver Manager]Specified driver could not be loaded followed by
- 0000 [iODBC][Driver Manager]NSLinkModule0 failed for dlopen()
The situation was bad, but neither message gave much insight into the actual problem, so it was time to test it in odbctest:
[troll:local/mysql/bin] aaa% odbctest
iODBC Demonstration program
This program shows an interactive SQL processor
Enter ODBC connect string (? shows list): ?
DSN | Description
---------------------------------------------------------------
test | myodbc
Enter ODBC connect string (? shows list): dsn=test
dyld errors during link edit for file
/Users/mysqldev/venu/local/mysql/lib/mysql/libmysqlclient.10.dylib
dyld: odbctest can't open library:
/Users/mysqldev/venu/local/mysql/lib/mysql/libmysqlclient.10.dylib
(No such file or directory, errno = 2)
Abort
[troll:local/mysql/bin] aaa%
Not surprisingly it still did not work, but the errors were more helpful. Looks like it can't find libmysqlclient.10.dylib and the reason appears to be that the directory it is looking for does not exist. MySQL does not get installed in OS X the same way as *nix and it appears that it was looking for the file in the standard *nix location. Well why not try a hack and symlink libmysqlclient.10.dylib into the directory structure it asks for and see what happens?
Off I go searching for libmysqlclient.10.dylib. First, I check the MySQL lib directory ... not there. Then I search the whole MySQL directory structure ... not there either. Finally, I give up and search the entire file system. Wait a second, libmysqlclient.10.dylib does not exist on my system. Looks like the closest thing is libmysqlclient.a.
A static library, that is not good. We need a dynamic library. (.dylib (as well as .so files, and .bundle files in Mac OS X) are dynamic libraries, which means when a program is compiled you only link to the file, you do not include the file in your executable. On the other hand .a files are static libraries, when a program is compiled you link to the file and the library is included in your executable. The problem here is that libmysqlclient.a is a static library and can not be dynamically linked.)
It looks like if I want to connect MySQL with MyODBC, I have to either recompile the MyODBC shared library and have it statically link to libmysqlclient.a, or recompile libmysqlclient as a shared library.
Other Options
I was not thrilled at the prospect of recompiling, as that would mean either mucking with the configure scripts or the makefiles, neither of which is fun. I was determined to get this to work though, so I back to the mysql.com site to download the MySQL debug package for OS/X (which includes the MySQL source code) and the MyODBC source code.
While downloading, I did some Googling to see if there were any places to find source code, documentation, FAQs, or anything else that would help in the endeavor. While I didn't find any helpful documentation, I did stumble across the Server Logistics OS X software site, which had a pkg distribution of MySQL that looked different from the one from mysql.com and its version claimed to include ODBC support. Figuring there was nothing to lose I decided to download the file and install it to see what it was all about.
After downloading, I backed up my MySQL data and removed the version of MySQL that I had installed. The Server Logistics package is a disk image (dmg) with several pkgs as well as documentation on how to set up, install and uninstall the software. I installed MySQL and the MyODBC packages and went to check out the lib's that were installed. In this case libmysqlclient was a dynamic lib. So far so good, so I restored my data and tried to setup ODBC again.
The first step was to set up the ODBC driver in iODBC's administrator. This was the same as the first time except the driver file was libmyodbc3.bundle and was located in /Library/MyODBC/lib. Next I setup the DSN, which was exactly the same as the previous setup.
Then came the test. First I tried the "Test" button on the "User DSN" and that gave an interesting response:
- HY000: [MySQL][ODBC 3.5.1] No DSN entered
Hmm... I thought that was a weird error, so I wanted to see what odbctest had to say:
[troll:~] aaa% /usr/bin/odbctest
iODBC Demonstration program
This program shows an interactive SQL processor
Enter ODBC connect string (? shows list): ?
DSN | Description
---------------------------------------------------------------
mysqltest | MyODBC
Enter ODBC connect string (? shows list): dsn=mysqltest
Driver: 03.51.06
SQL> show tables;
Tables_in_test
--------------
testaaa
result set 1 returned 1 rows.
Wow, looks like it worked! Now it was time to test it in an ODBC-compliant application, Excel V.x. (Note: When Excel V.x does ODBC queries it actually uses an application named Microsoft Query. Microsoft Query does not come in the standard distribution for Office V.x, so you may need to download it from Microsoft) Once inside Excel I choose "Data", "Get External Data", "New Database Query". This opens a screen that looks just like the iODBC manager screen. I choose the DSN I wanted to test, clicked "OK" and was now in the query form of Microsoft Query. As if by magic the table list for my database showed up on the right hand side of the screen. Crossing my fingers I ran a query and... voila!! I have an ODBC connection to my MySQL database.
Final Thoughts
After beating my head for a while, I did get MySQL to work with ODBC. It is unfortunate that the default distribution that mysql.com provides (and is likely the one that most people have installed) does not work out of the box with its ODBC drivers. This is the way it often goes with open source software, though. I would definitely recommend Server Logistics distribution however; it provides easy setup and has some goodies that are not provided in the standard distribution.
Andrew Anderson is a software developer and consultant in Chicago who's been using and programming on the Mac as long as he can remember.
Return to the Mac DevCenter.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 34 of 34.
-
Postgresql?
2004-09-07 08:56:10 ivetter [Reply | View]
Andrew,
Thanks for the article. We're looking forward to the postgresql, too.
Isaac
-
DSN problem
2004-06-25 10:08:44 rdupu [Reply | View]
I have installed the driver "libmyodbc3-3.51.06.bundle" with iODBC.
When I try to create an user dsn, I have the message : "An error occurred when trying to add the DSN : could not load the driver or translator setup library".
I go to Apple's ODBC manager to create a user dsn : I choose my driver, set SERVER, USER, Password & Database.
I launch iODBC test and have 2 messages : "specific driver could not be loaded" and "NSLinkModule failed for dlopen".
What's wrong will all this ? Thank you very much for your support !!!
-
Unknown MySQL Server Host
2004-01-07 07:35:50 anonymous2 [Reply | View]
I tried to set up ODBC and here is the message i have
DSN | Description
---------------------------------------------------------------
myodbc3 | primaire
Enter ODBC connect string (? shows list): dsn=myodbc3
[MySQL][ODBC 3.51 Driver]Unknown MySQL Server Host '???p"D@B?????? ' (1), SQLSTATE=HY000
-
remote server ?
2003-12-15 06:45:40 anonymous2 [Reply | View]
Hi,
Can odbc be used to connect to a mysql database on a remote machine? What if the remote machine is not a linux box?
I need to write an excel macro that would update the content of a worksheet by retrieving data from a mysql database. Any suggestions please...I am struggling with thing. Thanks for any help.
Siva
-
remote server ?
2003-12-15 06:47:57 anonymous2 [Reply | View]
I mistyped:
What if the remote server IS a linux box
-
remote server ?
2003-12-15 07:06:52 anonymous2 [Reply | View]
While I have not tested this, I do not see any reason why it should not work. The type of the server (Windows, Linux, OS X, whatever) should not matter as well.
You would need to set the host parameter to whatever the remote server is and verify that the remote server can be accessed remotely.
I would check out MySQL's Connector/ODBC manual at:
http://www.mysql.com/products/myodbc/manual.html
Andrew
-
Can't get this to work
2003-12-01 17:18:48 anonymous2 [Reply | View]
Just to be sure I reinstalled the MyODBC drivers from serverlogistics.
I run iODBC and install the driver, just using the out of the box odbc.ini file, and the libmyodbc3.bundle symlink. However, when I add a DSN, and select the driver, I get the following: "An error occurred when trying to add the DSN: Could not load the driver or translator setup library".
Otherwise, my MySQL installation is working fine. I just can't get ODBC working to save my life.
-
No DSN entered
2003-10-19 09:10:07 anonymous2 [Reply | View]
I followed the instructions and unfortunately, I can't get the ODBC to work. After installing iODBC, I went to test the datasource using iODBC test and I got the following message:
[MySQL][ODBC 3.51 Driver]No DNS entered
Just to clarify a few issues. When using iODBC, the first step was to open ODBC Drivers tab. Here I was asked for a description of the driver (I entered mysql). The next box asked for the Driver filename (I browsed to the driver in /Library/MyODBC/lib/). There are two files in this folder that could be the driver: libmyodbc3_r-3.51.06.bundle or libmyodbc3-3.51.06.bundle. I’ve tried both, but I’m not sure which one I should be using.
The next box asks for “Setup file name”. What goes in here?
I then went to the User DSN tab and I added a new User DSN. The first screen asks for the driver. I chose mysql.
I was then asked for the Data Source name. I used test. I entered the following key: value pairs: database: test;
username: root;
password: password.
I then tested the User DSN, but I get the error
[MySQL][ODBC 3.51 Driver]No DSN entered -
No DSN entered
2003-11-03 10:25:56 anonymous2 [Reply | View]
Ok, I got this to work. First of all, the iODBC test function often results in an error even when everything is working fine.
But the real cause of my problem, was that I had to configure MySQL to grant privileges to my user so that I could log on via iODBC.
Andrew
-
/usr/bin/odbctest works, but Excel and Query don't?!
2003-09-15 23:40:05 rkm28 [Reply | View]
I followed the directions above and was able to install the ODBC drivers through Server Logistic's Complete MySQL package. When I ran "odbctest" at the terminal, I had success.
However, when I run Excel (v.X) and choose "New Query", MS Query opens and says "ODBC is not installed on this system."
Any ideas on how I can get Query working? -
/usr/bin/odbctest works, but Excel and Query don't?!
2003-09-16 08:29:23 Andrew Anderson | [Reply | View]
Did you install iODBC's drivers or are you using Apple's drivers. The problem is that Excel is a CFM app, while Apple's drivers are Mach-O libraries. The type are not compatiable, but the iODBC drivers handles the bridging between the two.
Hope that helps.
-
There's something I missed, I think...
2003-08-22 11:27:41 anonymous2 [Reply | View]
I've tried to follow the article step by step and was lost at the second step: "I went to mysql.com and downloaded the MyODBC driver."
Am I wrong in saying that there's no MyODBC driver for Max OS X at mysql.com? I couldn't find any, but noone else seems to have the same problem... I'm confused.
So please, if anyone knows where to find the binary version of MyODBC for MacOS X that works with the packaged MySQL from mysql.com, I would appreciate a hint...
Thanks!
-
re: There's something I missed, I think...
2003-08-22 20:11:37 Andrew Anderson | [Reply | View]
Hi,
Looks like mysql.com removed the binary version of the MyODBC driver from there site since the writing of the article. My guess is that they removed it because it did not work, as I illustrate in the article and as a representative from MySQL acknowledged in a post.
If you follow the steps later on in the article which point you to the Server Logistics MySQL distribution, this appears to still work.
hope that helps,
Andrew
-
Permissions problem
2003-08-01 13:49:25 anonymous2 [Reply | View]
Got it all setup, using the Server Logistics setup (try there Apache 2 and PHP installs too!)
But when I try to connect with odbctest i get a message saying permissions denied, how do I set the username password details to auto-enter?
-
Kind of a difficult way to manage a database
2003-07-31 08:02:09 anonymous2 [Reply | View]
A much easier way is to use a tool like DataDino that has drivers built in. Try this, I dare you. Click on the link below or paste it into your browser:
http://www.datadino.com/dbexplorer/datadino.jnlp
I'll bet you that within 30 seconds of clicking that link, you'll be happily logged into your MySQL database. Or SQL Server if you prefer. Do ODBC drivers for SQL Server even exist under Mac OS X? -
re: Kind of a difficult way to manage a database
2003-07-31 08:46:18 Andrew Anderson | [Reply | View]
Are you some paid spokeman for DataDino that just does not understand ODBC ?
After looking at DataDino's website it is obvious that DataDino is a database management tool, much like dozens of other free and commercial products on the market. Database management tools are exactly as their name implies, tools to help you manage a database, ie/ test or update queries, look at data, check stored procedures (if they are applicable to the given system), etc.
ODBC is an industry standard protocol for accessing datasources without having to worry about knowing a closed interface to a given database system. This allows application writers to write generic code so they can access any complaint database without regard for who the vendor was, so long as the vendor or some outside source provided ODBC complaint drivers.
Explain to me how DataDino can be used to get data from a MySQL database into an Excel spreadsheet or a Word document, without saving a file or copying and pasting.
BTW ODBC drivers do exist for SQL Server under Mac OS X, Openlink SW provides them as well as ODBC drivers for almost any possible combination of OS and databse. Sybase (the actual authors of SQL Server, not Microsoft) also provide a full version of SQL Server on the Macintosh.
Andrew -
re: Kind of a difficult way to manage a database
2003-11-19 21:47:30 anonymous2 [Reply | View]
Hi,
In regards to the comment about Sybase and SQL server, I did not know that. Are you saying that there are free drivers for SQL server ODBC on OSX from Sybase? If so where can I find these!? The reason I ask is that the openlink SQL server drivers start at $99 and really for many uses you would need the $495.
This is one thing that I wish Apple would take the lead from Microsoft and provide all sorts of ODBC drivers with the OS like Windows does. I mean really what good is an ODBC manager without a driver???
Great article by the way. -
re: Kind of a difficult way to manage a database
2003-11-19 23:43:33 anonymous2 [Reply | View]
Unfortunately as far as I know that only Sybase/MS SQL Server drivers available for OS X are from OpenLink.
The point I was making in the comments was that it was possible to connect to these db's from OS X, not that the drivers were free or cheap.
I agree that Apple could be a lot more proactive about including ODBC features in general in OS X.
Glad you liked the article.
Andrew
-
Can I Get some help over here
2003-07-28 02:22:22 anonymous2 [Reply | View]
iODBC Demonstration program
This program shows an interactive SQL processor
Enter ODBC connect string (? shows list): ?
DSN | Description
---------------------------------------------------------------
myodbc3 | MySQL
Enter ODBC connect string (? shows list): myodbc3
libiodbcadm.so(5): Invalid access (permissions?)
[iODBC][Driver Manager]Dialog failed, SQLSTATE=IM008
Have a nice day.
-
Can I Get some help over here
2003-07-29 05:28:30 Andrew Anderson | [Reply | View]
You left out the "dsn=" when setting up the connection, ie/ it should be:
dsn=myodbc3
not
myodbc3
I tested it on my system and got the same error as you did when i left out the "dsn=" part.
assuming your dsn is setup correctly you should be ok.
Andrew
-
Useful but no FMP success
2003-07-21 06:18:58 anonymous2 [Reply | View]
That was very useful... I was having trouble with the DSN configuration in ODBC (I added host=localhost to the key pairs FWIW). I then tested it with "odbctest" (about which I had known nothing!) and bingo! my local MySQL DB appeared and I could run SQL queries on the command line.
Sadly though even after restarting FM 6.0 the data source doesn't appear in the Open... ODBC dialog (or Import ODBC)... frustrating!
Still, it's a start, and thanks again for a helpful article.
Paul -
Useful but no FMP success
2003-07-29 05:25:24 Andrew Anderson | [Reply | View]
iODBC's Mac Faq has info on how to get Filemaker setup, check out:
http://www.openlinksw.com/support/macosx-faq.htm#16
Seems you have to setup Filemaker to use the iODBC driver instead of the default DataDirect driver.
Hope that helps!
Andrew
-
How about a framework?
2003-06-30 08:22:41 anonymous2 [Reply | View]
Am I dreaming, or is there no 'official'
way to access ODBC in a cocoa program? -
How about a framework?
2003-07-14 10:45:48 macted [Reply | View]
Do you mean like these -- ?
/Library/ODBC/iODBC.framework
/Library/ODBC/iODBCadm.framework
/Library/ODBC/iODBCinst.framework
Please visit this page --
http://www.iodbc.org/opliodbc.htm
Complete, free, open-source iODBC SDKs (LGPL and BSD dual-licensed) are available for download, and include these Frameworks. All OpenLink's driver installers for Mac OS X also include the Frameworks.
I would also recommend checking out OpenLink's ODBC on the Mac FAQ (a work-in-progress) --
http://www.openlinksw.com/support/macosx-faq.htm
You can help get these Frameworks included in Panther, and perhaps even Mac OS X 10.2.7 or 10.2.8, by noting the need on Apple's site, either as a bug report, or as a forum posting.
Good luck,
Ted
Mac user since 1985
-
Oracle ODBC drivers
2003-06-24 17:01:49 anonymous2 [Reply | View]
As navigating Oracle's web site is on par with passing through the 7th circle of hell, can anyone give a tip as to how/where to get Oracle ODBC drivers for Mac OS X? -
Oracle ODBC drivers
2003-10-25 19:34:36 scienceman [Reply | View]
Easiest way is to register for and download the Developer Preview for Oracle 9i -- it is in there. The URL is
http://www.oracle.com/start/apple/intro.html
You can also get JDeveloper and JDBC drivers (if you need them) through that link.
See also http://www.macdevcenter.com/pub/a/mac/2002/11/12/oracle_part1.html and subsequent parts of this great article series.
-
MySQL AB is going to fix this!
2003-06-23 14:47:03 mark_mysql [Reply | View]
MySQL AB is committed to the end-user experience of our products on the Mac, and we're working to fix this for all users of MyODBC on Mac OS/X!
As has been already mentioned (in un-related threads) on the MyODBC mailing list, we're in the process of getting MyODBC builds with _statically_ linked libmysql code working to avoid problems such as the ones that the author of this article experienced.
If you have any other concerns about our product on Mac OS/X, please feel free to contact me directly (mark@mysql.com)!
Regards,
Mark Matthews, MySQL AB
-
Filemaker
2003-06-23 04:20:55 anonymous2 [Reply | View]
I've followed this tutorial and can now perform ODBC queries from excel (hurray!) - but how do I get this to work with FileMaker - the MyODBC driver doesn't show up in Filemaker or the "DataDirect ODBC" application that ships with it.
Any help is much appreciated
-
GPL issues with myODBC?
2003-06-22 22:25:26 anonymous2 [Reply | View]
I was looking at this the other day - I haven't been able to google how ODBC drivers are treated under the GPL.
The free download of myODBC is GPLed; AFAIK this means any program dynamically linking to it must also be GPL licensed. Does connecting to an ODBC driver qualify as dynamic linking?
There is an exemption for linking to components of the operating system - presumably this would mean linking to a GPL ODBC driver on Windows is not restricted, but on OS X (through the third party LGPL iODBC API), the client app must be GPL licensed?
I believe Openlink sell a commercial mySQL driver, but I'm still interested to know whether anyone has come across or knows the answer to this one.
Sam
-
Finally ODBC workin on OSX
2003-06-21 17:35:55 anonymous2 [Reply | View]
Thanks for finally enabling me to run ODBC on OSX - this has been the final stumbling block that has kept me having to keep a wintel machine on my desk (I can now swop it for a nice plant or a picture of the wife ;-) )
I had resorted to using a series of .php scripts that generated html tables that I could query using Excels "Web query" feature and a different set of scripts that output in XML format with an XSL file to translate to FileMaker format.
Now if only Microsoft Query didn't suck so much... ;-P
Once again thanks
Mm






If you download the MyODBC files from mysql.com, the INSTALL-BINARY instructions do not work.
I spent 2 hours trying to follow the instructions provided in the article, but the references to outside sources had changed or did not work as described in the article.
I recommend that no one follow this article's advice, and instead hammer on MySQL AB's door to create a simple MacOS X install for MyODBC. They made one for Windoze, why not Mac?