Connecting to a MySQL Database with ASOC

Hi.

This is my first post at MacScripter. I am following this forum a long time an i hope that my hint is interesting for you.

I was very surprised to see an article in an german mac coding magazin (Mac Developer 4/2010) about connecting from ObjC to an MySQL Database within a few lines of code. In this example some portions of C Code was used within ObjC. And from there ASOC can use it too!

All you need:
-is an MySQL installation from http://dev.mysql.com/downloads/connector/odbc/.
-a simple additional ObjC Class in your ASOC code.
-a few modifications in the build settings of the project

The additional build settings are as follows:
Other Linker Flags: -lz -lm -lmysqlclient
Header Search Paths: /usr/local/mysql/include/**
Library Search Paths: /usr/local/mysql/lib/**

You can find a zipped ASOC example here:
www.qusa.de/fileadmin/asoc/src/MySQL_Quicktest.zip

The resultset of the mysql query would be returned as an NSMutableArray.

The original ObjC Code:
http://www.mac-developer.de/content/download/3013/78453/file/2010-04%20MySQL.zip

My ObjC knowledge is very poor. Maybe you have hints to optimize the code.

Best Regards from germany
samowitsch

Model: MBP13
Browser: Safari 533.18.5
Operating System: Mac OS X (10.6)

That’s great. Thanks for sharing that. I also want to point out/ promote a Framework that I have been using to access a Microsoft SQL database - ODBCKit. I believe it can also access other ODBC databases as well, so this could very well handle MySQL also. It’s free at this point and is still under a little development (the dev helped hammer out a lot of bugs for my MS-SQL db).

http://www.druware.com/odbckit/
http://sourceforge.net/projects/odbckit/

In my implementation I also needed to have an ODBC driver installed, and I use Actual Technology’s driver.
http://www.actualtech.com/

I don’t have a stake in either of these products but I’d like to let programmers know so they can use them, and keep development going for all of us! The more native Mac database drivers, the more we can make inroads to business clients.

Chris