You are not logged in.
Pages: 1
Hi Arnaud,
I'm trying to use SynDBZeos to connect to a MySQL Database using the following:
fDatabase:TSQLDBConnectionProperties;
...
...
fDatabase := TSQLDBZEOSConnectionProperties.Create(ServerName, Databasename, Username, Password);
Servername is the hostname of the computer, Databasename is the databasename as created in MySQL, etc. etc.
The create seems to be executed without a problem, but when I get to 'res := fDatabase.ExecuteInlined(aSQLQuery, true);' I get a
EZSQLException with the message 'Requested Database driver was not found'. Apparently, it is unknown what the database is.
The question is, how do I provide the information to the constructor that the database is a MySQL database?
Cheers,
Wai
fpcdeluxe, FPC 3.2 / Lazarus 2.0, mORMot on Windows 10 ...
Offline
You have all the information at the constructor level of the class:
/// initialize the properties to connect to the ZEOS engine
// - aServerName shall contain the ZEOS URI, e.g:
// $ zdbc:firebird-2.0://127.0.0.1:3050/model?username=sysdba;password=masterkey
// $ sqlite
// i.e. '[zdbc:]PROTOCOL://HOST:PORT[/DATABASE][?paramname=value]'
// - you can define the TZConnection.LibraryLocation property by setting a
// '?LibLocation=...' parameter within the aServerName URL value
// - or simple use TSQLDBZEOSConnectionProperties.URI() class method
// - aDatabaseName, aUserID, aPassword are used if not already set as URI
// in aServerName value
// - you can use Protocols property to retrieve all available protocol names
constructor Create(const aServerName, aDatabaseName, aUserID, aPassWord: RawUTF8); override;
In short, the easiest is to use TSQLDBZEOSConnectionProperties.URI():
/// compute the ZEOS URI from a given database engine
// - you can set an optional full path to the client library name,
// to be completed on the left side with the executable path
// - possible use may be:
// ! PropsOracle := TSQLDBZEOSConnectionProperties.Create(
// ! TSQLDBZEOSConnectionProperties.URI(dOracle,'oci64\oci.dll'),
// ! 'tnsname','user',pass');
// ! PropsFirebird := TSQLDBZEOSConnectionProperties.Create(
// ! TSQLDBZEOSConnectionProperties.URI(dFirebird,'Firebird\fbembed.dll'),
// ! 'databasefilename','',');
class function URI(aServer: TSQLDBDefinition;
const aLibraryLocation: TFileName='';
aLibraryLocationAppendExePath: boolean=true): RawUTF8;
Take a look at the sample unit PerfMain.pas, in sample 15.
Note that MySQL is not fully tested (we do not use it here), so feedback is warmly welcome!
Offline
back again fiddling with SynDBZeos.
so when using function URI of TSQLDBZEOSConnectionProperties the function call would look like:
fDatabase := TSQLDBZEOSConnectionProperties.Create(TSQLDBZEOSConnectionProperties.URI(dMySQL, 'libmysql.dll'),
DatabaseProperties.DatabaseName,
DatabaseProperties.Username,
DatabaseProperties.Password );
I assume I have to provide the name of the MySQL lib, 'libmysql.dll' to the function.
Now I get an EZSQLException with the message 'Requested database driver was not found'. In my code this exception is raised at this statement:
res := fDatabase.ExecuteInlined(aSQLQuery, true);
aSQLQuery being a valid SQL statement.
If I inspect fDatabase, I see that fServerName is 'mysql'. Shouldn't this be
the name of the server where MySQL is running?
Last edited by wai-kit (2013-05-06 15:39:42)
fpcdeluxe, FPC 3.2 / Lazarus 2.0, mORMot on Windows 10 ...
Offline
I did not check dMySQL kind of engine by now (only Oracle + FireBird + SQlite3).
But using TSQLDBZEOSConnectionProperties.URI() sounds the right way to do it.
Please step in the debugger to see what is happening.
Offline
Pages: 1