Serving MySQL on Linux machine w/C++ Windows access
I have successfully installed and am running MySQL on a linux box (Ubuntu). I can manipulate my database using phpmyadmin from any browser on my local network as long as I open the appropriate firewalls.
My question is why can I use phpmyadmin in a browser, and MySQL commands in a Windows command window, but I CANNOT get the database to be recognized by the C++ code running on the Windows machine?
I have tested this on my C++ development machine. I can both use phpmyadmin in a browser, and I can use MySQL in a Windows command window. I have created a fixed address for my linux server which is running MySQL as part of the XAMPP distribution. The IP address of the Linux Server is XXX.XXX.XXX.101.
My Windows machine is running Windows Vista and its IP address is generated by DHCP (e.g. it is not fixed).
I am using the Windows connector for C++ and when I try to execute the code:
-----
#define DBHOST "tcp://XXX.XXX.XXX.101:3306"
#define USER "myusername"
#define PASSWORD "mypassword"
#define DATABASE "mydatabase"
int main() {
Driver *driver;
Connection *con;
/* initiate url, user, password and database variables */
string url = DBHOST;
const string user = USER;
const string password = PASSWORD;
const string database = DATABASE;
try {
driver = get_driver_instance();
/* create a database connection using the Driver */
cout << url << " - " << user << " - " << password << endl;
con = driver -> connect(url, user, password);
} catch (SQLException &e) {
cout << "ERROR: SQLException in " << __FILE__;
cout << "ERROR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << ")" << endl;
}
-----
I get the error message:
ERROR: Unknown MySQL server host '_' (11004) (MySQL error code: 2005, SQLState: HY000)
Subject
Views
Written By
Posted
Serving MySQL on Linux machine w/C++ Windows access
1072
April 12, 2010 11:24AM
413
April 15, 2010 12:38AM
563
April 15, 2010 08:04AM
388
June 03, 2010 10:06PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.