Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "mysql_connection.h"
- #include <cppconn/driver.h>
- #include <cppconn/exception.h>
- #include <cppconn/resultset.h>
- #include <cppconn/statement.h>
- int main()
- {
- string Username;
- string Pass;
- try
- {
- sql::ResultSet *res;
- sql::ResultSet *res2;
- sql::Driver *driver;
- sql::Connection *con;
- sql::Statement *stmt;
- bool loggingin = true;
- driver = get_driver_instance();
- con = driver->connect([inserpassword stuff]);
- con->setSchema("sql2271023");
- stmt = con->createStatement();
- res = NULL;
- res2 = NULL;
- while (loggingin) {
- printf("Please Type Your Username: \n >>");
- cin >> Username;
- printf("Please Type Your Password: \n >>");
- cin >> Pass;
- stmt->executeQuery("SELECT Password WHERE UserName = '" + Username + "'"); -- at this line Unhandled exception at 0x00007FF89BA1A388 in SecretProject.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x000000CECFAF7220
- res = stmt->executeQuery("SELECT Password WHERE UserName = '" + Username + "'");
- res2 = stmt->executeQuery("SELECT HWID WHERE UserName = '" + Username + "'");
- res = stmt->executeQuery("Get Password where Username = '" + Username + "'");
- string password = res->getString(1);
- res2->next();
- while (res->next()) {
- if (res->getRow() == 0 || password != Pass) {
- printf("Username or Password Wrong");
- }
- else {
- if (res2->getString(1) != getHWID()) {
- exit(1);
- }
- else {
- loggingin = false;
- }
- }
- break;
- }
- }
- delete con;
- delete res;
- delete res2;
- delete stmt;
- }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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement