Databse & C++?

Discussion about everything. New games, 3d math, development tips...
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Databse & C++?

Post by monkeycracks »

Anyone know of a good library for any kind of database and C++? Rather than using IrrNet for logins and such I think this would be more affective and reduce in-game lag for those actually playing at the time.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

Well, I tried Interbase, Firebird but both need a server installation /easy/.
Several days ago I found SQLite :wink: and tested it with C++Builder.
http://www.sqlite.org/
No installs are necessary, server is implemented like just one dll. Also sources are available too. Google it, also you can download SQLite3 manager LITE for database design:
http://www.filedepot.eu/
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

I couldn't seem to get it compiled, any others in preferably C++ with good documentation on how to use it?
It's going to be incorporated into my Irrlicht Project, it can't be a standalone program.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Reviving this old thread, I need this more than ever now :

A library for MySQL and C++ that can connect to a database online somewhere and exchange data with it. That means re-writing, adding, removing, etc. data.

Anyone got teh goods?
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

Post by strale »

Hi

Sorry i am not sure if this is what you are looking for,

I used MySQL linked to ODBC using windows.h API
But the software (C++) run on a intranet and in this case on the server.
i do not know if you can link trhou the internet via ODBC .
You probably would need to make a client server using this way

if i am not wrong MySql has dll to link C/C++ to the database
but in this way you would have to pay as the GPL has limitation to link DLL staticly to your code, so i used ODBC.

Cheers
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

So I have to pay to use my database on my webserver?

:|
Down wit teh government!
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

Post by strale »

No you have not to pay to use your database but to use "my sql"
:P

But i get information +- a year ago as i needed for a commercial product.
Maybe something is changed.

then if you use through ODBC it 's totally free also for commercial products (always information of 1 year ago).

to access to MySql table via ODBC is not defficult you can find a lot info on the internet or if you decide in this way and need help let me know.

then you probably need to have access via the internet, could i suggest using sokets?
or PHP with your webserver
or reading the forum i saw that tere are library to easy use network
but i never tried them

bye
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

monkeycracks wrote:So I have to pay to use my database on my webserver?

:|
Down wit teh government!
no you have to pay for a lisence to use their code commercially.

this has nothing to do with the government nor your code.. there are other solutions but you won't find them here most likly.
TheC
Posts: 93
Joined: Fri May 05, 2006 7:50 am

Post by TheC »

If you sell the product containing the MySQL libraries, you gotta pay. Its expensive :)

if OO isn't important, you can just use the MySQL library provided in their download.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

My project isn't commercial :P

And even though it's got nothing to do with the government, they should still die :)

So I'll search up on ODBC.
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

Post by strale »

Well so for the ODBC friends and cultists, i give some more info about it

- it 's a Microsoftw "library" to access database but i remembere that there was something also for Linux

- It is slow for uge number of data (tousands records for seconds ) so for some kind of work it better to use direct access to the database

- it is only a link so you need a database but you can also use a text file as database

- link a database you have to :
configure the ODBC in panell control, on the intranet server or on local computer , mainly give a name, the directory where your DB is located, and select a driver for the specified Database.


- call windows API to deal with ODBC (there are also library to do this )
but to trouble a bit more it is suggested to use windows API Here there are some:


///Initialize the job
:D // Allocate Environment
sr = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hOdbcEnv);
:) // Set the App's ODBC Version
sr = SQLSetEnvAttr(hOdbcEnv, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER);
:( // Allocate Connection
sr = SQLAllocHandle(SQL_HANDLE_DBC, hOdbcEnv, &hDbConn);
:cry: // Set Connect Timeout and other parameters
sr = SQLSetConnectAttr(hDbConn, SQL_ATTR_LOGIN_TIMEOUT, (void*)20, 0);
:shock: sr = SQLSetConnectAttr(hDbConn, SQL_ATTR_ACCESS_MODE, SQL_MODE_READ_WRITE, 0);
:P // Connect to Data Source
sr = SQLConnect(hDbConn, (UCHAR *)sDSN, SQL_NTS,(UCHAR *)szUID, SQL_NTS,(UCHAR *) szAuthStr, SQL_NTS);


once configurate the link and connected to database , we can enjoy ourselves

Sending query
:? // Allocate new Statement Handle based on previous connection
sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);
sr = SQLExecDirect(hstmt, (SQLCHAR *) strSQL, SQL_NTS);
..................
// and free the statment after execution
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);

Bind data from a previous query to read data
8) sr = SQLBindCol( hstmt, (SQLUSMALLINT)pColNumber, SQL_C_CHAR,(SQLPOINTER) cPointer ,ipMaxLen, & ValueLenOrInd);

and read then
:lol: sr = SQLFetch(hstmt) ;

Kill'em all :twisted:
//Disconnect from database
SQLDisconnect(hDbConn);
//Free connection
SQLFreeHandle(SQL_HANDLE_DBC, hDbConn);
//Free environment
SQLFreeHandle(SQL_HANDLE_ENV, hOdbcEnv);


Hope it could be useful
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

So you know, you don't have to specify the DSN information in the control panel. You can specify it through function calls as well.

Last time I actually used ODBC, I did so on Linux, with an Informix database( in 2001 ). I'll see if I can dig up the code.
Image
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

Post by strale »

Hi Spintz

I did not know about this feature
it 's very interesting, I always used pannel controll forgetting often of it and wasting a lot of tinme thinking about what was wrong.

cheers
fra
Posts: 14
Joined: Thu Apr 13, 2006 6:36 pm
Contact:

Post by fra »

hi,
few months ago i presented the ETNA lib topic here.
At this time i thought it was the best way for me to connect on a database. But i'd like to know if i shouldn't use another library (like ODBC for example). What do you think about it ?
PS: i read that some servers ( the free.fr servers for example) doesn't accept external request. is it true ?
KIC : frateamkic.info
(i'm frensh so scuse me for my english ...)
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

most database servers for websites only allow connections from the localhost, that way people can't access the data in the database from other websites. It's very unsecure to open a database up to the general public, maybe another specific IP address, but not just any IP address.
Image
Post Reply