Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBX Framework Error Can't connect to MySQL server on 'localhost'

Status
Not open for further replies.

gudeads

Programmer
Mar 20, 2009
2
Hello everyone,

I have a problem connectin to a mysql database server and I have no idea where the problem is.
I am using Codegear Delphi 2007 and DBX4 Framework.
This is the code:

Debug.Add('Before Connection Factory');
ConnectionFactory := TDBXConnectionFactory.GetConnectionFactory;
Debug.Add('Before Properties Create');
ConnectionProps := TDBXProperties.Create();
Debug.Add('Before Properties fill');
ConnectionProps.Add(TDBXpropertyNames.ConnectionName, 'macaddr');
ConnectionProps.Add(TDBXpropertyNames.DriverName, 'MYSQL');
ConnectionProps.Add(TDBXpropertyNames.HostName, 'mysql.ccag');
ConnectionProps.Add(TDBXpropertyNames.Database, 'CCD1');
ConnectionProps.Add(TDBXpropertyNames.UserName, 'apache');
ConnectionProps.Add(TDBXpropertyNames.Password, 'apache');
Debug.Add('Before GetConnection');
Connection := ConnectionFactory.GetConnection(ConnectionProps);



On the GetConnection method I get an exception:
'Can't connect to MySQL server on 'localhost' (10061)'

Now I don't understand why the server in the exception is localhost when I set it in the DBXProperties under 'HostName'

Can anyone help me

Thank you in advance
Marco
 
Do you have 'MySQL Administrator' or 'MySQL Query Browser' installed on your workstation? I ask because if you can see your tables with these utilities, it's simply a matter of matching the log-in parameters to the properties of your application. Besides, I've found that without them is much like working in the dark.

Roo
Delphi Rules!
 
Hi roo0047,
I'va installed 'MySQL Administrator' or 'MySQL Query Browser' and with both of them I can connect with exactly the same user and password. But my Delphi program give me always the same error.
Any idea?

thanks

Marco
 
It sounds like it's the connection string itself (hostname or database) has something incorrect. I'm not up on Delphi 2007 or DBX4. (I use D7 with Zeos which requires file 'libmySQL.dll' in my path). Perhaps this link, titled "Delphi 2007 and DBX" by Dr Bob will help or another member will jump in. Sorry I could not be more help.

Roo
Delphi Rules!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top