10 messages in com.mysql.lists.plusplusRe: Strange behavior of connect() whe...
FromSent OnAttachments
António Santos27 Feb 2008 07:58 
Warren Young27 Feb 2008 18:12 
António Santos28 Feb 2008 06:45 
Warren Young28 Feb 2008 13:05 
Warren Young28 Feb 2008 13:15 
António Santos29 Feb 2008 01:27 
William F. Dowling29 Feb 2008 07:00 
Warren Young29 Feb 2008 12:08 
António Santos06 Mar 2008 06:32 
Warren Young06 Mar 2008 23:43 
Subject:Re: Strange behavior of connect() when specifying a different port
From:António Santos (ansa@fe.up.pt)
Date:02/29/2008 01:27:50 AM
List:com.mysql.lists.plusplus

Hi Warren,

if (!conn.connect("wgwps", "127.0.0.1", "ans", "bns", 4040))

The address may be the problem. The C API recognizes special addresses like this and can interpret them oddly. Try "localhost" instead.

I tried with "localhost" and it is still connecting to 3306...

perror("Connection::connect");

By the way, this isn't the best way to handle MySQL++ errors. In this instance, what perror appends to your string will only be correct if the connection failure is due to an error return from a system call. If something else goes wrong, such as the server rejecting your login parameters, it will tell you something like "no error" because the last system call to run probably succeeded.

Far better is to either a) enable exceptions, getting the error message from the exception object; or b) call either Query::error() or Connection::error() (same thing) to get the error message.

Yeah, I know that. This is not my final code, just a snippet to test this issue. Thanks for the advice! I really don't know what is going on since if I use the C API directly, everything works ok...

Thanks,