A customer called our office recently saying that they could not make Rad Studio connect to a MySQL database, and that an internet search on how to do this had yielded no results. I’ve been using MySQL with Delphi for years, and so this is a situation I set out to remedy….
The problem…
Lets start by taking a look at the issue. Start up Rad Studio and create a new application (VCL or FMX/Firemonkey), and drop a TFDConnection component on the main form…
Double click on the connection and select “MySQL” from the combo list titled “Driver ID”
Now fill in the fields for “Database”, “Username”, “Password”, and “Server” for your MySQL database, and click the “Test” button. You’ll first be presented with another connection dialog (click “OK”) and then the following error message…
Okay, so lets take a look at how to fix this problem…
The Solution…
The error message presented is a warning that the Rad Studio IDE can’t find “libmysql.dll” Kernel security check failure. which is the driver library required to connect to your MySQL database. So far as I am aware, there is no single package for downloading this driver by it’s self, if anyone knows of one, and it’s both legal and conforming to the license agreement, please let me know and I’ll update this post. For now however, you must download an entire MySQL installation package and extract the required DLL file(s). The driver file is the same for MySQL Community server as for the corresponding commercial server of the same version.
Visit http://dev.mysql.com/downloads/mysql/ and download the ZIP Archive files for BOTH 64-bit and 32-bit installations of MySQL server.
Extract both packages to separate locations.
Create a new directory structure to look something like this…
The dll name for 64-bits is precisely the same as that for 32-bits, and so we’ve created separate 32 & 64 bit directories to keep them separated. Now within both extracted directories “mysql–win32″ and “mysql–winx64″ navigate down into the “lib” directory and take a copy of “libmysql.dll” – Place each into their respective 32 or 64 bit directory within the “MySQL Client Libraries” directory that you created earlier.
You may now trash all of the MySQL server install files (zips and extracted directories), just keep your “MySQL Client Libraries” directory with the client libraries inside.
Now take a copy of the 32-bit “libMySQL.dll” file and place it somewhere which appears on your path when the IDE is running.
I’m dropping mine into “:windowssystem32”.
Edit:Do not place the DLL into “:program files (x86)EmbarcaderoStudio<version>bin” as I’d previously suggested in this blog post. It was unknown to me at the time of writing, that placing anything in the Rad Studio “bin” directory will really upset your IDE installation!
This will enable the IDE to see the required driver library file at design time.
Note: The RadStudio IDE is a 32-bit application, regardless of the bitedness (is that a word?) of your version of windows. Hence you must use the 32-bit driver to enable the IDE to connect to MySQL databases.
Repeat the steps in the beginning of this post (under, “The Problem”) to create a MySQL connection at design-time. You should no longer get the error message but instead…
Making it work at runtime…
That’s great for design time, but what about your application at runtime? Well this is where you have some choices to make.
For your application to see the driver while running inside the IDE, you could copy the 32-bit version of the library into your Debug binary directory for 32-bits, and the 64-bit version into your 64-bit debug directory. To do this you’ll first have to build the application for both targets so that the relevant debug directories are created, and then copy the library dll files.
One alternative would be to place a copy of the MySQL driver library somewhere on the system path (such as “.windowssystem32″ for example) but this will only work for one target (32 or 64-bit).
When the time comes for you to deploy your application, you’ll also need to ship the dll’s for the relevant target platform. If you ship the 32-bit and 64-bit versions of your application in a single package, you likely already separate the executables into different directories, so simply ship the relevant dll version inside those directories.
Conclusion
You now have the power of the FireDAC framework to use against the excellent MySQL database! Go forth and make database applications! For additional information, see the official documentation for RadStudio here.
Thanks for reading!
No matter what I do, I cant seem to connect to Firebird 2.5 embedded database using Firedac. Funny thing is that yesterday it seemed to work, now all of a sudden it just wont.
Rather to rake my head why all of a sudden it ceased to work, I begun rebuilding a clean project so I can figure out step by step what is going on. I added (copied) the entire contents of the downloaded package from Firebird to my application directory and the database itself of course.
To avoid folder issues I have set the Delphi environment options to put all the files ( and the exe in the same directory. Then I used the suggestion found in the Firebird *.doc folder and renamed fbembed.dll to fbclient.dll. (On some Firedac Q&A about the issue I have read that Firedac requires fbembed.dll file. Well, I have tried both ways and it wont work anyway..). But let me stick to first issue with fbclient.dll.
To establish a connection I have dropped on the datamodule a FDPhysFBDriverLink1 and a FDConnection1.
Now the FDPhysFBDriverLink1: It's BaseDriverID is FB. For DriverID I have tried both suggesions:First with 'FB' and then supplying the full path to the fbclient.dll. None seem to make the difference.
When I go to Firedac Connection editor and input the path to my database file, I get 'Cannot load vendor library (fbclient.dll or fbembed.dll) .. error. But both of these files ARE in the application exe folder (like suggested on embarcadero site). So where is Firedac looking for the files ? I am getting a little fed up of Firebird and the Firedac as they can't simply explain what must be done for the connection to succeed. All they give is some vague options which none of them work. Add this-add that.. and at the end..fail.
So if someone has experience on how to do this with straight forward answer (no links please..I have seen and tried them all) I would very much appreciate it. Trying for days to establish a simple connection is really stupid. I have tried also with Unidac with similar results. So before I get the 99th nervous breakdown, what must I do to accomplish the connection ?
delphifirebirddelphi-xe6firedacfirebird-embedded| this questionedited Aug 16 '14 at 15:13MartynA 13.6k 2 13 41 asked Aug 16 '14 at 14:47 rajevosa 77 1 8 I can't place it immediately but ISTR there was a question here a few weeks ago about Firebird embedded suddenly stopping working. You might try looking for it in case anyone came up with an answer. – MartynA Aug 16 '14 at 14:59 | 2 Answers---Accepted---Accepted---Accepted---
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |