il codice è quello del resetdb.cpp
Cioè:
codice:
#include <windows.h>
#include <iostream>
#include <sqlplus/sqlplus.hh>
#pragma comment (lib,"mysql++.lib")
int main (int argc, char *argv[]) {
Connection connection(use_exceptions);
try { // the entire main block is one big try block;
if (argc == 1) connection.connect("");
else if (argc == 2) connection.connect("",argv[1]);
else if (argc == 3) connection.connect("",argv[1],argv[2]);
else if (argc <= 4) connection.connect("",argv[1],argv[2],argv[3]);
// create a new object and connect based on any (if any) arguments
// passed to main();
try {
connection.select_db("mysql_cpp_data");
} catch (BadQuery er) {
// if it couldn't connect to the database assume that it doesn't exist
// and try created it. If that does not work exit with an error.
connection.create_db("mysql_cpp_data");
connection.select_db("mysql_cpp_data");
}
Query query = connection.query(); // create a new query object
try { // ignore any errors here
// I hope to make this simpler soon
query.execute("drop table stock");
} catch (BadQuery er) {}
query << "create table stock (item char(20) not null, num bigint,"
<< "weight double, price double, sdate date)";
query.execute(RESET_QUERY);
// send the query to create the table and execute it. The
// RESET_QUERY tells the query object to reset it self after
// execution
query << "insert into %5:table values (%0q, %1q, %2, %3, %4q)";
query.parse();
// set up the template query I will use to insert the data. The
// parse method call is important as it is what lets the query
// know that this is a template and not a literal string
query.def["table"] = "stock";
// This is setting the parameter named table to stock.
query.execute ("Hamburger Buns", 56, 1.25, 1.1, "1998-04-26");
query.execute ("Hotdogs' Buns" ,65, 1.1 , 1.1, "1998-04-23");
query.execute ("Dinner Roles" , 75, .95, .97, "1998-05-25");
query.execute ("White Bread" , 87, 1.5, 1.75, "1998-09-04");
// The last parameter "table" is not specified here. Thus
// the default value for "table" is used which is "stock".
} catch (BadQuery er) { // handle any errors that may come up
cerr << "Error: " << er.error << endl;
return -1;
}
}
Guarda, gli errori che dà sono molti perchè anche in altri files di intestazione, e non ho avuto tempo di andare a vedere, anche perchè mi ritroverei smarrito.
Dà alcuni errori del tipo:
Esecuzione di g++.exe...
g++.exe "C:\Dev-Cpp\Examples\MySQLClientTest\resetdb.cpp" -o "C:\Dev-Cpp\Examples\MySQLClientTest\resetdb.exe" -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
In file included from C:/Dev-Cpp/include/coldata1.hh:9,
from C:/Dev-Cpp/include/mysql++:11,
from C:/Dev-Cpp/include/mysql++.h:2,
from C:/Dev-Cpp/Examples/MySQLClientTest/resetdb.cpp:3:
C:/Dev-Cpp/include/type_info1.hh:14: friend declaration requires class-key,
i.e. `friend struct mysql_type_info'
C:/Dev-Cpp/include/type_info1.hh:15: friend declaration requires class-key,
i.e. `friend struct mysql_ti_sql_type_info_lookup'
C:/Dev-Cpp/include/type_info1.hh:44: friend declaration requires class-key,
i.e. `friend struct mysql_type_info'
In file included from C:/Dev-Cpp/include/row1.hh:12,
from C:/Dev-Cpp/include/compare1.hh:6,
from C:/Dev-Cpp/include/mysql++:12,
from C:/Dev-Cpp/include/mysql++.h:2,
from C:/Dev-Cpp/Examples/MySQLClientTest/resetdb.cpp:3:
C:/Dev-Cpp/include/resiter1.hh:29: wrong number of template arguments (2,
should be 1)
C:/Dev-Cpp/include/c++/bits/stl_iterator.h:91: provided for `template<class
_Iterator> class std::reverse_iterator'
C:/Dev-Cpp/include/resiter1.hh:29: ISO C++ forbids declaration of `
reverse_iterator' with no type
C:/Dev-Cpp/include/resiter1.hh:30: wrong number of template arguments (2,
should be 1)
C:/Dev-Cpp/include/c++/bits/stl_iterator.h:91: provided for `template<class
_Iterator> class std::reverse_iterator'
C:/Dev-Cpp/include/resiter1.hh:30: ISO C++ forbids declaration of `
const_reverse_iterator' with no type
In file included from C:/Dev-Cpp/include/c++/backward/strstream:51,
from C:/Dev-Cpp/include/sql_query1.hh:4,
from C:/Dev-Cpp/include/manip1.hh:10,
from C:/Dev-Cpp/include/vallist1.hh:4,
from C:/Dev-Cpp/include/row1.hh:13,
from C:/Dev-Cpp/include/compare1.hh:6,
from C:/Dev-Cpp/include/mysql++:12,
from C:/Dev-Cpp/include/mysql++.h:2,
from C:/Dev-Cpp/Examples/MySQLClientTest/resetdb.cpp:3:
C:/Dev-Cpp/include/c++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
In file included from C:/Dev-Cpp/include/manip1.hh:10,
from C:/Dev-Cpp/include/vallist1.hh:4,
from C:/Dev-Cpp/include/row1.hh:13,
from C:/Dev-Cpp/include/compare1.hh:6,
from C:/Dev-Cpp/include/mysql++:12,
from C:/Dev-Cpp/include/mysql++.h:2,
from C:/Dev-Cpp/Examples/MySQLClientTest/resetdb.cpp:3:
C:/Dev-Cpp/include/sql_query1.hh:30: friend declaration requires class-key,
i.e. `friend struct MysqlQuery'
C:/Dev-Cpp/include/sql_query1.hh:121: friend declaration requires class-key,
i.e. `friend class SQLQueryParms'
In file included from C:/Dev-Cpp/include/manip1.hh:12,
from C:/Dev-Cpp/include/vallist1.hh:4,
from C:/Dev-Cpp/include/row1.hh:13,
from C:/Dev-Cpp/include/compare1.hh:6,
from C:/Dev-Cpp/include/mysql++:12,
from C:/Dev-Cpp/include/mysql++.h:2,
from C:/Dev-Cpp/Examples/MySQLClientTest/resetdb.cpp:3:
C:/Dev-Cpp/include/set1.hh:12: parse error before `>' token
C:/Dev-Cpp/include/set1.hh:18: parse error before `&' token
C:/Dev-Cpp/include/set1.hh:18: `void operator()(...)' must be a nonstatic
member function
C:/Dev-Cpp/include/set1.hh:18: confused by earlier errors, bailing out
Esecuzione terminata
Suggeritemi che fare
Grazie
Ciao
PS: dimenticavo....provando l'exe già compilato nel pacchetto mysql++ funziona quindi a livello di connessione ci siamo poiche mi crea il database la tabella stock e fa l'insert.