[prev in list] [next in list] [prev in thread] [next in thread]
List: mysql-plusplus
Subject: Re: Beginner question -- Tutorial example
From: Carlos Moreno <moreno () mochima ! com>
Date: 2001-06-13 15:17:38
[Download RAW message or body]
Hi Greg, thanks for your message!
> i think you need to add the switch to the library directory to
> your compile command.
I guess that was not necessary on my machine (well, my web hoster's
machine) because the files libsqlplus.so* are on /usr/lib (which is
the default library directory, I guess).
> on a freeBSD box, we use the following
>
> c++ -I/usr/local/include/mysql -L/usr/local/lib -lsqlplus source1.cc -o source
Seems identical to the command I used, except that I seem to have
the libraries installed to /usr instead of to /usr/local
So, it would seem like I do have a problem with my code? :-(
I can't see any difference between it and the example from the
tutorial (well, other than the actual table and stuff...)
Below is the code (it's not too long, so I hope I'm not breaking
any netiquette in this list :-)).
When I run it from the console, the output shows "4 records found"
(there are indeed four records in the table), then the first row
(it has two fields: ID (int), and name (char(20))), then three
blank lines, and then "segmentation fault (core dumped)".
Do you see anything wrong with it? Any suggestions as to extra
code (validation, debugging) that I could place to narrow down
the problem?
Thanks for any further ideas!
Cheers,
Carlos
--
#include <iostream>
using namespace std;
#include <sqlplus.hh>
int main()
{
Connection db ("...", "localhost", "...", "...");
// I removed the confidential information -- in the
// actual program, the dbname, user, and password
// are there
Query query = db.query();
query << "select * from prueba";
Result res = query.store();
cout << "Content-type: text/plain\n\n";
cout << "Found " << res.size() << " records!\n\n";
Row record;
for (Result::iterator row = res.begin(); row != res.end(); row++)
{
record = *row;
cout << record[0] << '\t' << record[1] << endl;
}
return 0;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic