Java Student's Profile
Reputation: 5
Worker
- Group:
- Contributor w/DIC++
- Active Posts:
- 394 (0.33 per day)
- Joined:
- 05-February 10
- Profile Views:
- 11,288
- Last Active:
Today, 08:58 AM- Currently:
- Offline
Previous Fields
- Country:
- Who Cares
- OS Preference:
- Windows
- Favorite Browser:
- FireFox
- Favorite Processor:
- Intel
- Favorite Gaming Platform:
- Playstation
- Your Car:
- Who Cares
- Dream Kudos:
- 75
Latest Visitors
-
macosxnerd101 
Yesterday, 04:43 PM -
SarumanTheWhite 
07 May 2013 - 06:33 -
darek9576 
05 May 2013 - 01:27 -
aaron1178 
05 May 2013 - 00:58 -
Chrisx18 
02 May 2013 - 21:18 -
Programmerkid115 
30 Apr 2013 - 17:55 -
ronan085 
25 Apr 2013 - 07:02 -
GunnerInc 
20 Apr 2013 - 19:54 -
el_pancho 
19 Apr 2013 - 13:53 -
modi123_1 
30 Mar 2013 - 21:37
Posts I've Made
-
In Topic: SQL linking errors
Posted 21 May 2013
It works now, but I had to manually create my own database and not one that was automatically created when I installed MySQL.
There's one thing I still don't understand. CTphpnwb pointed out that localhost=your computer, so when other computers try to connect to my computer's server database, is won't let them because the program thinks the database is on their computer?
If so, should I make "host=my IP" or "host=my IP:default port" so the program knows where to connect to my database? Because I see no one online using anything other than "host=localhost". -
In Topic: SQL linking errors
Posted 20 May 2013
I'm thinking it is a sample database. I can't find any documentation on the setSchema function.
It is necessary per step 4 in MySQL doc's on setting up the c++ connector for visual studio (link)
It's only the setting of the database that gives me the error, ie:
con->setSchema("Local instance MYSQL56") -
In Topic: SQL linking errors
Posted 20 May 2013
Local instance MYSQL56 didn't work. I assumed it was only MySQL56 because that's what I entered when I created the db, and MySQL automatically added Local instance. -
In Topic: SQL linking errors
Posted 20 May 2013
I want to simply connect to my database by using the MySQL doc's example (MySQL example 1).
I'v commented out the querying in the example because I don't want to deal with querying yet, just connecting to my database.
/* Copyright 2008, 2010, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. There are special exceptions to the terms and conditions of the GPL as it is applied to this software. View the full text of the exception in file EXCEPTIONS-CONNECTOR-C++ in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* Standard C++ includes */ #include <stdlib.h> #include <iostream> /* Include directly the different headers from cppconn/ and mysql_driver.h + mysql_util.h (and mysql_connection.h). This will reduce your build time! */ #include "mysql_connection.h" #include <cppconn/driver.h> #include <cppconn/exception.h> #include <cppconn/resultset.h> #include <cppconn/statement.h> using namespace std; int main(void) { cout << endl; cout << "Running 'SELECT 'Hello World!' » AS _message'..." << endl; try { sql::Driver *driver; sql::Connection *con; sql::Statement *stmt; sql::ResultSet *res; /* Create a connection */ driver = get_driver_instance(); con = driver->connect("localhost", "root", "pass"); /* Connect to the MySQL test database */ con->setSchema("test"); //stmt = con->createStatement(); //res = stmt->executeQuery("SELECT 'Hello World!' AS _message"); //while (res->next()) { // cout << "\t... MySQL replies: "; // /* Access column data by alias or column name */ // cout << res->getString("_message") << endl; // cout << "\t... MySQL says it again: "; // /* Access column fata by numeric offset, 1 is the first column */ // cout << res->getString(1) << endl; //} //delete res; //delete stmt; //delete con; } catch (sql::SQLException &e) { cout << "# ERR: SQLException in " << __FILE__; cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl; cout << "# ERR: " << e.what(); cout << " (MySQL error code: " << e.getErrorCode(); cout << ", SQLState: " << e.getSQLState() << " )" << endl; } cout << endl; system("pause"); return EXIT_SUCCESS; }
This is my server/database setup:

Starting with the code above, I get this output:

Which connects fine, but that's weird because I have no database named "test" :S
So when I change "test" to "MySQL56", which actually is one of my databases, I get a console window with text scrolling down the console at 100mph, which I would assume means there's a problem connecting to MySQL56. So why does it connect fine to a database "test", which doesn't exist, while it doesn't with MySQL56, a database that exists? -
In Topic: SQL linking errors
Posted 20 May 2013
Then how will others be directed to my server if im supposed to leave the hostname as localhost?
My Information
- Member Title:
- D.I.C Regular
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
-
- Interests:
- Programming, math, linear algebra, physics and computer science.
- Years Programming:
- 1
- Programming Languages:
- Java, CSS, html
Contact Information
- E-mail:
- Private
- MSN:
-
Private
|
|


Find Topics
Find Posts
View Reputation Given




|
Comments
harshwal92
01 Sep 2011 - 06:06javabie
08 Mar 2010 - 21:17I didn't realize you are Canadian too until now.
Java Student
27 Feb 2010 - 21:21nagcarlangurlz
27 Feb 2010 - 10:13nagcarlangurlz
27 Feb 2010 - 10:11