Hello,
I am trying to run the following code:
Can anyone help please?
Thanks in advance,
Julien.
I am trying to run the following code:
try { sql::Driver *driver; sql::Connection *con; sql::Statement *stmt; sql::ResultSet *res; driver = get_driver_instance(); con = driver->connect("tcp://localhost:3306", "root", "root"); con->setSchema("`hull-db`"); stmt = con->createStatement(); res = stmt->executeQuery("SELECT * FROM chapitre"); while (res->next()) { cout << "num" << res->getInt("numero_chapitre"); cout << "titre" << res->getString("titre_chapitre"); } delete res; delete stmt; delete con; } catch (sql::SQLException &e) { cout << "ERR: " << e.what(); cout << "MySQL error code: " << e.getErrorCode(); cout << "SQLState: " << e.getSQLState(); }And I get the following error:
*** glibc detected *** ./cppapplication-01: free(): invalid pointer: 0x08cd4f58 *** ======= Backtrace: ========= /lib/tls/i686/cmov/libc.so.6(+0x6b591)[0xac9591] /lib/tls/i686/cmov/libc.so.6(+0x6cde8)[0xacade8] /lib/tls/i686/cmov/libc.so.6(cfree+0x6d)[0xacdecd] /usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x693741] /usr/lib/libstdc++.so.6(_ZNSs4_Rep10_M_destroyERKSaIcE+0x1d)[0x66fc2d] /usr/lib/libstdc++.so.6(_ZNSsD1Ev+0x4c)[0x6715dc] ./cppapplication-01[0x8049629] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0xa74bd6] ./cppapplication-01[0x8048fd1] ======= Memory map: ======== 00110000-00134000 r-xp 00000000 08:05 3080667 /lib/tls/i686/cmov/libm-2.11.1.so 00134000-00135000 r--p 00023000 08:05 3080667 /lib/tls/i686/cmov/libm-2.11.1.so 00135000-00136000 rw-p 00024000 08:05 3080667 /lib/tls/i686/cmov/libm-2.11.1.so 00136000-00153000 r-xp 00000000 08:05 3063988 /lib/libgcc_s.so.1 00153000-00154000 r--p 0001c000 08:05 3063988 /lib/libgcc_s.so.1 00154000-00155000 rw-p 0001d000 08:05 3063988 /lib/libgcc_s.so.1 00155000-00205000 r-xp 00000000 08:05 7283646 /usr/lib/libstdc++.so.5.0.7 00205000-0020a000 rw-p 000af000 08:05 7283646 /usr/lib/libstdc++.so.5.0.7 0020a000-0020f000 rw-p 00000000 00:00 0 0020f000-00219000 r-xp 00000000 08:05 3080677 /lib/tls/i686/cmov/libnss_files-2.11.1.so 00219000-0021a000 r--p 00009000 08:05 3080677 /lib/tls/i686/cmov/libnss_files-2.11.1.so 0021a000-0021b000 rw-p 0000a000 08:05 3080677 /lib/tls/i686/cmov/libnss_files-2.11.1.so 002f1000-002f2000 r-xp 00000000 00:00 0 [vdso] 002f2000-00518000 r-xp 00000000 08:05 7686038 /usr/lib/mysql-connector-c++-1.0.5/libmysqlcppconn.so.1.0.5 00518000-00556000 rw-p 00226000 08:05 7686038 /usr/lib/mysql-connector-c++-1.0.5/libmysqlcppconn.so.1.0.5 00556000-00557000 rw-p 00000000 00:00 0 005d8000-006c1000 r-xp 00000000 08:05 7283335 /usr/lib/libstdc++.so.6.0.13 006c1000-006c2000 ---p 000e9000 08:05 7283335 /usr/lib/libstdc++.so.6.0.13 006c2000-006c6000 r--p 000e9000 08:05 7283335 /usr/lib/libstdc++.so.6.0.13 006c6000-006c7000 rw-p 000ed000 08:05 7283335 /usr/lib/libstdc++.so.6.0.13 006c7000-006ce000 rw-p 00000000 00:00 0 0089d000-008b8000 r-xp 00000000 08:05 3063813 /lib/ld-2.11.1.so 008b8000-008b9000 r--p 0001a000 08:05 3063813 /lib/ld-2.11.1.so 008b9000-008ba000 rw-p 0001b000 08:05 3063813 /lib/ld-2.11.1.so 00944000-0094d000 r-xp 00000000 08:05 3080665 /lib/tls/i686/cmov/libcrypt-2.11.1.so 0094d000-0094e000 r--p 00008000 08:05 3080665 /lib/tls/i686/cmov/libcrypt-2.11.1.so 0094e000-0094f000 rw-p 00009000 08:05 3080665 /lib/tls/i686/cmov/libcrypt-2.11.1.so 0094f000-00976000 rw-p 00000000 00:00 0 00a5e000-00bb1000 r-xp 00000000 08:05 3080662 /lib/tls/i686/cmov/libc-2.11.1.so 00bb1000-00bb2000 ---p 00153000 08:05 3080662 /lib/tls/i686/cmov/libc-2.11.1.so 00bb2000-00bb4000 r--p 00153000 08:05 3080662 /lib/tls/i686/cmov/libc-2.11.1.so 00bb4000-00bb5000 rw-p 00155000 08:05 3080662 /lib/tls/i686/cmov/libc-2.11.1.so 00bb5000-00bb8000 rw-p 00000000 00:00 0 00cdd000-00cf0000 r-xp 00000000 08:05 3080672 /lib/tls/i686/cmov/libnsl-2.11.1.so 00cf0000-00cf1000 r--p 00012000 08:05 3080672 /lib/tls/i686/cmov/libnsl-2.11.1.so 00cf1000-00cf2000 rw-p 00013000 08:05 3080672 /lib/tls/i686/cmov/libnsl-2.11.1.so 00cf2000-00cf4000 rw-p 00000000 00:00 0 00d5c000-00d71000 r-xp 00000000 08:05 3080690 /lib/tls/i686/cmov/libpthread-2.11.1.so 00d71000-00d72000 r--p 00014000 08:05 3080690 /lib/tls/i686/cmov/libpthread-2.11.1.so 00d72000-00d73000 rw-p 00015000 08:05 3080690 /lib/tls/i686/cmov/libpthread-2.11.1.so 00d73000-00d75000 rw-p 00000000 00:00 0 08048000-0804d000 r-xp 00000000 08:01 6946898 /home/julien/NetBeansProjects/CppApplication-01/dist/Debug/GNU-Linux-x86/cppapplication-01 0804d000-0804e000 r--p 00004000 08:01 6946898 /home/julien/NetBeansProjects/CppApplication-01/dist/Debug/GNU-Linux-x86/cppapplication-01 0804e000-0804f000 rw-p 00005000 08:01 6946898 /home/julien/NetBeansProjects/CppApplication-01/dist/Debug/GNU-Linux-x86/cppapplication-01 08cd4000-08cf5000 rw-p 00000000 00:00 0 [heap] b6e00000-b6e21000 rw-p 00000000 00:00 0 b6e21000-b6f00000 ---p 00000000 00:00 0 b6fea000-b6feb000 ---p 00000000 00:00 0 b6feb000-b77ef000 rw-p 00000000 00:00 0 b7807000-b780a000 rw-p 00000000 00:00 0 bf9aa000-bf9bf000 rw-p 00000000 00:00 0 [stack]
Can anyone help please?
Thanks in advance,
Julien.