New Posts  All Forums:Forum Nav:

C++ Databases

post #1 of 11
Thread Starter 
Hey guys, can anyone link or post some info about accessing databases with C++? I know what a database is, i know how to work with em using php and/or java, but I have no idea how to do that in C++ (which is the one i love). I'm using Visual Studio 2010 Pro atm. Searching around i found some stuff using #include and #include but there is not a single working - complete example confused.gif, it would be great to be able to use MySQL but i tried to read some stuff about MySQL connector and i just couldn't get it.
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
post #2 of 11
http://dev.mysql.com/tech-resources/articles/mysql-connector-cpp.html
Intellect v2
(9 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7-6700K Processor ASUS ROG MAXIMUS VIII HERO LGA1151 DDR4 M.2 SAT... EVGA GTX 1080 SC ACX 3.0 Crucial Ballistix Sport 32GB DDR4 2400 MT/s (PC... 
CoolingKeyboardPowerCase
Noctua NH-D15 Das Keyboard 4 Professional (Brown) Corsair AX860 Fractal Design Define R5 
Mouse
MIONIX NAOS 7000 
  hide details  
Reply
Intellect v2
(9 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7-6700K Processor ASUS ROG MAXIMUS VIII HERO LGA1151 DDR4 M.2 SAT... EVGA GTX 1080 SC ACX 3.0 Crucial Ballistix Sport 32GB DDR4 2400 MT/s (PC... 
CoolingKeyboardPowerCase
Noctua NH-D15 Das Keyboard 4 Professional (Brown) Corsair AX860 Fractal Design Define R5 
Mouse
MIONIX NAOS 7000 
  hide details  
Reply
post #3 of 11
Thread Starter 
Ok that didn't help, best i could get was a run-able code with includes only, as soon as i touch any of the MySQL stuff it goes horribly wrong lol, with includes only i mean something like this:
Code:
#include <iostream>
#include <string>

#include <cppconn/connection.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include "mysql_connection.h"
#include "mysql_driver.h"

using namespace std;

int main(){

    return 0;
}

I get this if i try to compile with some actual code on it:
Code:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sql::SQLException::~SQLException(void)" (__imp_??1SQLException@sql@@UAE@XZ) referenced in function __catch$_main$0
1>boost.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall sql::SQLException::getErrorCode(void)const " (__imp_?getErrorCode@SQLException@sql@@QBEHXZ) referenced in function __catch$_main$0
1>boost.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sql::SQLString::~SQLString(void)" (__imp_??1SQLString@sql@@QAE@XZ) referenced in function _main
1>boost.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sql::SQLString::SQLString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0SQLString@sql@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
1>boost.obj : error LNK2019: unresolved external symbol __imp__get_driver_instance referenced in function _main
1>boost.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __thiscall sql::SQLString::asStdString(void)const " (__imp_?asStdString@SQLString@sql@@QBEABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "class std::basic_ostream<char,structstd::char_traits<char> > & __cdecl std::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class sql::SQLString const &)" (??6std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABVSQLString@sql@@@Z)

I'm not sure, maybe I'm just being tard right now, but in order for it to compile at fist i had to download Boost libraries, then i had to manually create and copy-paste some code for a file called SQLString.h cos its needed but not included, is like, too much stuff for something that should be so easy imho rofl
Edited by NorCa - 4/19/11 at 10:59pm
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
post #4 of 11
It is easy, if you aren't on Windows.

My guess is you have to set some include and library paths up in your VC++ project config.
Underground
(14 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 920 C0 ASUS P6T6 WS Revolution GTX 460 TR3X6G1600C8D 
Hard DriveOptical DriveCoolingOS
WD1001FALS SAMSUNG SH-S223F 22X DVD MULTI Corsair H50 Fedora 16 KDE x86_64 
MonitorKeyboardPowerCase
HP w19b Microsoft Comfort Curve Corsair CX600 Thermaltake Armor VA8003BWS 
MouseMouse Pad
Razer DeathAdder Black 
  hide details  
Reply
Underground
(14 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 920 C0 ASUS P6T6 WS Revolution GTX 460 TR3X6G1600C8D 
Hard DriveOptical DriveCoolingOS
WD1001FALS SAMSUNG SH-S223F 22X DVD MULTI Corsair H50 Fedora 16 KDE x86_64 
MonitorKeyboardPowerCase
HP w19b Microsoft Comfort Curve Corsair CX600 Thermaltake Armor VA8003BWS 
MouseMouse Pad
Razer DeathAdder Black 
  hide details  
Reply
post #5 of 11
Thread Starter 
I'm all ears, i use netbeans for Java with CYGWIN for G++, im guessing thats pretty much the same thing as linux
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
post #6 of 11
Quote:
Originally Posted by NorCa;13199343 
I'm all ears, i use netbeans for Java with CYGWIN for G++, im guessing thats pretty much the same thing as linux

Not quite the same. I suppose cygwin might work, but I don't have a Windows box handy to test with.

I think that soon you are going to be a happy Linux user. biggrin.gif
Underground
(14 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 920 C0 ASUS P6T6 WS Revolution GTX 460 TR3X6G1600C8D 
Hard DriveOptical DriveCoolingOS
WD1001FALS SAMSUNG SH-S223F 22X DVD MULTI Corsair H50 Fedora 16 KDE x86_64 
MonitorKeyboardPowerCase
HP w19b Microsoft Comfort Curve Corsair CX600 Thermaltake Armor VA8003BWS 
MouseMouse Pad
Razer DeathAdder Black 
  hide details  
Reply
Underground
(14 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 920 C0 ASUS P6T6 WS Revolution GTX 460 TR3X6G1600C8D 
Hard DriveOptical DriveCoolingOS
WD1001FALS SAMSUNG SH-S223F 22X DVD MULTI Corsair H50 Fedora 16 KDE x86_64 
MonitorKeyboardPowerCase
HP w19b Microsoft Comfort Curve Corsair CX600 Thermaltake Armor VA8003BWS 
MouseMouse Pad
Razer DeathAdder Black 
  hide details  
Reply
post #7 of 11
Thread Starter 
I've used Linux before but its simply not for me, alternative programs imo (please note the imo) are not as good, not to mention games.
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
post #8 of 11
Quote:
Originally Posted by NorCa;13207054 
I've used Linux before but its simply not for me, alternative programs imo (please note the imo) are not as good, not to mention games.

It depends on what you're trying to accomplish. smile.gif
Underground
(14 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 920 C0 ASUS P6T6 WS Revolution GTX 460 TR3X6G1600C8D 
Hard DriveOptical DriveCoolingOS
WD1001FALS SAMSUNG SH-S223F 22X DVD MULTI Corsair H50 Fedora 16 KDE x86_64 
MonitorKeyboardPowerCase
HP w19b Microsoft Comfort Curve Corsair CX600 Thermaltake Armor VA8003BWS 
MouseMouse Pad
Razer DeathAdder Black 
  hide details  
Reply
Underground
(14 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 920 C0 ASUS P6T6 WS Revolution GTX 460 TR3X6G1600C8D 
Hard DriveOptical DriveCoolingOS
WD1001FALS SAMSUNG SH-S223F 22X DVD MULTI Corsair H50 Fedora 16 KDE x86_64 
MonitorKeyboardPowerCase
HP w19b Microsoft Comfort Curve Corsair CX600 Thermaltake Armor VA8003BWS 
MouseMouse Pad
Razer DeathAdder Black 
  hide details  
Reply
post #9 of 11
The error you are getting is because you have included the header files but not the libraries.

From the page linked above:
Quote:
Both statically linked and the dynamically linked Connector/C++ driver can be found in lib directory under the driver installation directory

When installing you need the header files to be in your "include" directory and the libraries to be in your "lib" directory. You also need to actually link with these libraries in your project configuration and finally any shared libraries (dlls) need to be on the PATH or in the same directory as the executable.

The include and lib directories for visual studio can be found somewhere similar to (depending on your architecture and version of visual studio) C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include and \lib. When you are referencing header files from this include directory use #include not #include "foobar"

This answer applies to any "unresolved external symbol" error.
Quote:
Originally Posted by NorCa;13207054 
alternative programs imo are not as good

Really depends on the program. Would you argue that VLC is not as good as Windows Media Player, for example? The Windows version of VLC is really just a port.
Edited by ghell - 4/23/11 at 1:02pm
Serene Power
(13 items)
 
  
CPUMotherboardGraphicsRAM
Dual Xeon E5620 Supermicro X8DAL-i EVGA 570HD SC 8GiB Corsair DDR3 1333 ECC-R 
Hard DriveOptical DriveOSMonitor
OCZ Agility 3 120GB SSD (+16TB NAS) LG 10x Blu-Ray Windows 7 x64 / Debian x64 Dell 2408WFP, P2411H 
PowerCase
850W CoolerMaster SilentPro M CoolerMaster Cosmos Pure 
  hide details  
Reply
Serene Power
(13 items)
 
  
CPUMotherboardGraphicsRAM
Dual Xeon E5620 Supermicro X8DAL-i EVGA 570HD SC 8GiB Corsair DDR3 1333 ECC-R 
Hard DriveOptical DriveOSMonitor
OCZ Agility 3 120GB SSD (+16TB NAS) LG 10x Blu-Ray Windows 7 x64 / Debian x64 Dell 2408WFP, P2411H 
PowerCase
850W CoolerMaster SilentPro M CoolerMaster Cosmos Pure 
  hide details  
Reply
post #10 of 11
Thread Starter 
I solved my problem, i believe i needed to copy libmysql.dll into windows/system folder, although i finally did it using mysql server source files(not mysql connector), using mysql.h, it contains everything needed. Didn't try with the connector after copying the file.

Just chill about linux, as i mentioned, i used it before for myself and for work but for now and the near future i don't see myself going linux till they decide to make something better than directx, photoshop, foobar, 3dsmax; btw of course i love/use vlc, but, it runs on windows tongue.gif
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
Atroc.V3.2
(16 items)
 
Home Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
i5 2500k [Asrock] Z77E-ITX [EVGA] GTX 770 [Samsung] 8GB 30nm 
Hard DriveCoolingCoolingOS
[Crucial] M4 64Gb [Silverstone] NT06-PRO [Gelid] 120mm PWM Windows 7 Ultimate x64 
MonitorKeyboardPowerCase
[Samsung] 22" [Microsoft] Sidewinder X4 [Silverstone] SFX450w [Silverstone] SG05 
MouseAudioOtherOther
[Microsoft] Sidewinder [Shure] SRH-840 [Shiit] Magni [Schiit] Modi 
CPUMotherboardRAMHard Drive
[AMD] Athlon X3 450 [Asus] M4A785TD-V Evo [Corsair] 4GB XMS3 DDR3 [Western Digital] 200Gb 
Hard DriveOptical DriveOSPower
[Western Digital] 2Tb [Acer] DVD RW ArchLinux [CoolerMaster] Elite 460w 
Case
[NZXT] Gamma 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming