Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8638625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:46:44+00:00 2026-06-12T10:46:44+00:00

Following the syntax from the MySQL site on the MySQL C++ connector but not

  • 0

Following the syntax from the MySQL site on the MySQL C++ connector but not having good results, here is a snippet:

#include "/usr/include/mysql++/mysql++.h"
#include "/usr/include/mysql/mysql.h"
#include "/usr/include/mysql/mysql_version.h"
#include "/usr/include/mysql_connection.h"
#include "/usr/include/mysql_driver.h"
#include <cppconn/driver.h>
#include <cppconn/connection.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>


using namespace std;
using namespace sql::mysql;
using namespace sql;


sql::mysql::MySQL_Driver *driver;
driver = sql::mysql::get_mysql_driver_instance();
sql::Connection *con;
con = driver->connect("tcp://127.0.0.1:3306", "db", "password");
sql::PreparedStatement  *prep_stmt;
prep_stmt = con->prepareStatement("INSERT INTO db(srcIP, srcCountry, destIP, destHost, destPort, blIP) VALUES (?, ?, ?, ?, ?, ?)");

    prep_stmt->setString(1, src_ip);
    prep_stmt->setString(2, country_code);
    prep_stmt->setString(3, dest_ip);
    prep_stmt->setString(4, host_name);
    prep_stmt->setString(5, dest_prt);
    prep_stmt->setString(6, blip);
    prep_stmt->execute();

    delete prep_stmt;
    delete con;

            }
        else

sql::mysql::MySQL_Driver *driver;
driver = sql::mysql::get_mysql_driver_instance();
sql::Connection *con;
    con = driver->connect("tcp://127.0.0.1:3306", "db", "password");
sql::PreparedStatement *prep_stmt;
    prep_stmt = con->prepareStatement("INSERT INTO db(srcIP, srcCountry, destIP, destHost, destPort, blIP) VALUES (?, ?, ?, ?, ?, ?)");

    prep_stmt->setString(1, src_ip);
    prep_stmt->setString(2, country_code);
    prep_stmt->setString(3, dest_ip);
        prep_stmt->setString(4, he->h_name);
    prep_stmt->setString(5, dest_prt);
    prep_stmt->setString(6, blip);
    prep_stmt->execute();

    delete prep_stmt;
    delete con;

Compiling with:

g++ sql.c -o sql -I/usr/include -I/usr/include/mysql -I/usr/include/mysql++ -I/usr/local/include -I/usr/local/include/cppconn -lmysqlcppconn -lmysql++ -lstdc++ -lmysqlpp -lmysqlclient

and alway get the error on the second set of MySQL Driver:

error: ‘driver’ was not declared in this scope

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:46:46+00:00Added an answer on June 12, 2026 at 10:46 am

    Based only on what I can see, it looks like you are missing braces around the statements you wish to be part of the else case. If you do this:

    if (x)
    {
       // do something
    }
    else
       Foo* foo = new foo();
       foo->someFunction();
    

    You will get the error on the line which reads foo->someFunction(); because the else contains only a single statement without braces and foo goes out of scope after that. You need to do this:

    if (x)
    {
       // do something
    }
    else
    {
       Foo* foo = new foo();
       foo->someFunction();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following mysql query but get a syntax error: Unknown column 'k.Fund_Name'
I come from mySQL to SQL Server. Doesn't the following syntax work in SQL
I have following MYSQL syntax but when I am running it , it gives
(Related to, but separate from Syntax error with emulating "create user if not exists"
I have following syntax in my script to get email address from string. The
I'm trying to use is_member_pointer from the type_traits header, with the following syntax, for
Why do I always get the following error from Postgres? syntax error at or
I know the following MySQL code is not correct can some help me fix
I'm trying to use the following query syntax from a php file: $sql =
I'm trying to write a sql query to the following (from this site http://sqlzoo.net/1b.htm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.