FAQ

FAQ

Postby Devart » Wed 17 Aug 2005 11:34




Are the MyDAC connection components thread-safe?

Yes, MyDAC is thread-safe but there is a restriction. The same MyConnection cannot be used in several threads. So if you have multithreaded application you should have its own Connection set for each thread that uses MyDAC.


How can I determine what MyDAC version I use?

You can do it in several ways:

  • in the folder where you have installed MyDAC see history.txt file

  • at design-time in the main menu see MySQL About MyDAC

  • at run-time inspect value of MYDACVersion and DACVersion constants

  • the exact version of MyDAC is shown when you install it

When a query is executing cursor changes to hour-glass. How can I disable this behaviour?

You need to write at any place in your project DBAccess.ChangeCursor := False;


On execution of Post or Delete methods I get an exception EDatabaseError with the message 'Update failed. Found %d records.'
On RefreshRecord execution I get an exception EDatabaseError with the message 'Refresh failed. Found %d records.'

This error takes place when server is unable to determine what record to modify or delete. In other words, there are either many or no records that suit UPDATE criteria. Such situation can happen when you omit unique field in SELECT statement (TCustomDADataSet.SQL) or when another user modifies the table simultaneously. This exception can be suppressed. Refer to TCustomMyDataSet.Options.StrictUpdate topic in MyDAC help for more information.


How can I execute a query written to TMyQuery.SQLInsert (SQLUpdate, SQLDelete, SQLRefresh) property?

These queries are processed automatically on execution of Post, Delete, and RefreshRecord methods. Usually there is no need to fill these properties as text of the query is generated automatically.


I cannot use BIGINT and INT UNSIGNED fields as key fields in master-detail relationship.
On setting Field.Value the value is lost or an exception is raised.

Fields of this type are represented in Delphi as TLargeIntField. You cannot access these fields through Value property. See db.pas TLargeintField.SetVarValue for details.
As a solution, you can change field type to INT - this is usually enough for key field.Or you can avoid using Value.


On accessing server I get 'MySQL server has gone away' or 'Lost connection to MySQL server during query' error.

First of all, you should find out what causes the problem. The list of most-frequent reasons follows:

  • Client side: too small value of TMyConnection.ConnectionTimeout or TCustomMyDataSet.CommandTimeout. To check this hypothesis try setting TCustomMyDataSet.CommandTimeout to 0 (infinitive) and TMyConnection.ConnectionTimeout to 300.

  • Server side: MySQL server has closed connection. You can read detailed description of all possible reasons in MySQL Reference Manual but almost always it is because of too small value of wait_timeout variable. Try increasing it. If this solution is not possible (for example, because you don't have enough rights), you should call MyConnection.Ping with interval less than wait_timeout. Use TTimer in TMyConnection thread to accomplish this task.

  • Unstable connection (GPRS etc). Use CachedUpdates mode with InnoDB tables. In case of very unstable connection switch to "disconnected" model by using TSimpleDataSet (TClientDataSet).

In case of connection loss MyDAC tries to reconnect to server. However, your last command is probably not executed and you should repeat it again. MyDAC does not try to reconnect if transaction is started or at least one of statements is prepared.


On MyDAC installation I get a message "Setup has detected already installed DAC packages which are incompatible with current version."
I installed MyDAC but on starting IDE I get a message "Procedure entry point ... not found in ..."
MyDAC was installed successfully but when I compile my project I get a message "Unit ... was compiled with a different version of ..."

You can have such problems if you installed incompatible MyDAC, SDAC or ODAC versions. All these products use common base packages. The easiest way to avoid the problem is to uninstall all installed DAC products and then download from our site and install the last builds.


How productive is MyDAC?

MyDAC uses low-level protocol to access server. This allows to reach high performance. Time from time we compare MyDAC with another products, and MyDAC always takes the first place.


I would like to develop an application that works with MySQL Server. What should I use - MyDAC or DbxMda?

dbExpress technology serves for most possible unification of accessing different servers (MS SQL, MySQL, Oracle and so on). It is based on drivers including server-specific features. Like any universal tool, in most specific cases dbExpress loses some functionality. For example, dbExpress design-time is quite poor and cannot be expanded.

MyDAC is a specialized set of components to access MySQL server with advanced design-time and with component interface similar to BDE.

We tried to implement maximal MySQL support in DbxMda and MyDAC. However, dbExpress technology puts severe restrictions. For example, Unicode fields cannot be passed from the driver to dbExpress.

MyDAC and DbxMda use the same kernel and thus have similar performance. In some cases dbExpress is slower because data undergoes additional conversion to correspond to dbExpress standards.

Drawing a line, if it is important to be able to adapt your application quickly to database server other than MySQL, you'd better use DbxMda. At the rest cases, especially on migration from BDE or ADO, you should use MyDAC.


What software should be installed on a client computer so that my applications that use MyDAC can run?

Generally you do not need any additional files. Below you can see the only exceptions:

  • If you use MySQL Embedded server (TMyConnection.Options.Embedded = True or TMyEmbConnection),
    you need the server itself (libmysqld.dll) and service files for it, for example errmsg.sys.

  • If you use standard client (TMyConnection.Options.Direct = False), you need libmysql.dll.

  • If you use SSL (TMyConnection.Options.Protocol = mpSSL), you need library files for OpenSSL - ssleay32.dll and libeay32.dll.


When I try to connect to the server I get an error "MySQL client library couldn't be loaded."

You use TMyConnection.Options.Direct := False mode and client library dll is not available for your application.

Windows:
You should copy client file libmysql.dll to the folder available for executable unit of your program. For example, to the folder with exe-file or to the system folder Windows. For more details see description of LoadLibrary and environment variable PATH.
Linux:
You should copy client file libmysqlclient.so.X to the folder available for executable unit of your program. For more details see description of dlopen environment variable LD_LIBRARY_PATH.


When I try to install MyDAC packages under Kylix I get an error "Invalid package"

Probably you use Kylix Open Edition. MyDAC doesn't support this Kylix version.


Sometimes my application hangs on applying changes to database.

The problem occurs because MyISAM tables get locked in a read/write collision. If you try to update a table that is not fetched out, MySQL blocks the thread and waits till the table is completely fetched. Please refer to MySQL Reference manual section Locking Issues for details.

Try setting other type of the table, for example, InnoDB. You can also set FetchAll property to True.


I have problems with working with temporary tables.
I have problems with working with transactions.

Most likely you use FetchAll = False mode. Unfortunately use of FetchAll = False with all its advantages has some restrictions. Set FetchAll to True to avoid them. You can read more about it in MyDAC help (TCustomDADataSet.FetchAll topic).


Why does Locate function work so slowly?

If you set FetchAll = False and then call Locate, MyDAC fetches all rows from the server to perform the operation. On subsequent calls Locate works much faster.


How can I get a list of databases at the server?

Use TMyConnection.GetDatabaseNames method.


How can I get a list of tables in the database?

Use TMyConnection.GetTableNames method.


I set Debug property but nothing happens!
While executing a query screen cursor doesn't change to hour-glass.
If I have LoginPromp=True, the connect dialog does not appear.

You should add to your uses list MyDacVcl (for Windows) or MyDacClx (for Linux) unit.

Devart
Devart Team
 
Posts: 3108
Joined: Tue 26 Oct 2004 13:51

Return to MySQL Data Access Components