Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » mySql - how to use - what is needed?
mySql - how to use - what is needed? [message #34676] Mon, 05 December 2011 15:58 Go to next message
Wolfgang is currently offline  Wolfgang
Messages: 146
Registered: November 2011
Location: Germany
Experienced Member
Hi,

I try to connect to a mysql server which is on another machine (over the local network)... so I have no mysql server installation on the machine i try to write a program with U++ - also no installtion path.

Can someone step me through the process to connect to the remote mysql server? Searched the reference and the examples but it don't work... if I include the mysql package in my project i get a
Quote:

d:\ultimate++\upp\uppsrc\mysql\MySql.h(12) : fatal error C1083: Cannot open include file: 'MySql.h': No such file or directory
error (I think because I haven't set up any paths or whatever for mysql).

best regard

Wolfgang
Re: mySql - how to use - what is needed? [message #34680 is a reply to message #34676] Mon, 05 December 2011 17:18 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Wolfgang,

I believe you have to have MySql client libraries installed. This step of course depends on what OS you use Smile

Then create MySqlSession object and call its Connect() method with appropriate parameters (server name, port, database etc...). Also, did you see the docs? The code on that page is for local server, but if you look at the Connect method signature, you'll see it is equally simple to connect to remote database.

Best regards,
Honza
Re: mySql - how to use - what is needed? [message #34681 is a reply to message #34680] Mon, 05 December 2011 19:50 Go to previous messageGo to next message
Wolfgang is currently offline  Wolfgang
Messages: 146
Registered: November 2011
Location: Germany
Experienced Member
Here I'm running Windows 7...

Am I right that
Quote:

http://dev.mysql.com/downloads/

Quote:

Connector/ODBC(Current Generally Available Release: 5.1.9) Standardized database driver Windows, Linux, Mac OS X, and Unix platforms.

is the ODBC Layer which provides less performance than the
Quote:

Connector/C++(Current Generally Available Release: 1.1.0) Standardized database driver for C++ development.
?

I saw the docs but in it it's nothing what I need to download..
the connection to a local server differs just by local = "localhost" or "127.0.0.1" and the remote is connected throught the full http / network path?!
Re: mySql - how to use - what is needed? [message #34699 is a reply to message #34681] Tue, 06 December 2011 19:31 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi Wolfgang,

I have an application used where I am working in IRL and I pass only the IP adress of the server where the MySql (version 5.5) is installed. The application has been developped with U++ and connection is done using native MySql. Hereafter is the code snippet for your information. Server identifier contains the IP (193.xxx.xxx.xx) of the Win Server. "dbrisks" is the name of the MySql database.

if(rmSession.Connect(cnxStr.At(3),cnxStr.At(4),"dbrisks",server,ScanInt(cnxStr.At(2),NULL,10))){
SQL = rmSession;
SQL *Select(SqlCountRows()).From(TBLUSERS).Where(IDENTIFIER==cnx Str.At(3));

while(SQL.Fetch())
if(SQL[0]!=0)
{
SetLogonInUse(cnxStr.At(3));
msgStatusBar<<cnxStr.At(3);
msgStatusBar<<t_(" connecté");

rmImageDisplay.setConnectionStatus(true);
rmStatusBar.Set(0,msgStatusBar,200);
rmMenuBar.Set(THISBACK1(SetMainMenu,true));
}
else Exclamation("[*A2@5 "+DeQtfLf(t_("Cet utilisateur n'existe pas !.'\n'Il faut le créer."))+"]");
}
else {
errorMessage<<t_("ERREUR SQL: ")<<'\n'<<t_("Impossible d'établir une connexion au serveur !")<<'\n'<<t_("L'application va être fermée par sécurité");
PanicMessageBox(t_("Erreur connexion"),errorMessage);
Close();
}
}

cnxStr.Clear();
}


Native connection is preferable to ODBC socket when database begin to contain a lot of records. Definitively it is better to use it in production.

if you need more information or help do not hesitate to ask Razz .

Regards

Biobytes
Re: mySql - how to use - what is needed? [message #34701 is a reply to message #34699] Tue, 06 December 2011 20:31 Go to previous messageGo to next message
Wolfgang is currently offline  Wolfgang
Messages: 146
Registered: November 2011
Location: Germany
Experienced Member
Thank you BioBytes for the snippet but what packages do you use / what have you downloaded (from mysql.com?) to make this "rmSession.Connect(" work?
Re: mySql - how to use - what is needed? [message #34944 is a reply to message #34701] Mon, 19 December 2011 14:32 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi Wolfgang,

Sorry for late reply but I was out of possibility to connect to U++ website for a while.

I just add the MySql package (<MySql/MySql.h>) in the header file. You need to install the MySql server to test your application (http://dev.mysql.com/downloads/mysql/) and also the administration tools (http://dev.mysql.com/downloads/workbench/5.2.html) for creating accounts and manage the different databases.

You could also find useful help in the U++ topics (MySql/native connection) starting with U++ 4193).

If some difficulties please let me know

Kind regards

Biobytes
Re: mySql - how to use - what is needed? [message #34947 is a reply to message #34681] Mon, 19 December 2011 16:44 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Wolfgang wrote on Mon, 05 December 2011 19:50


Connector/ODBC(Current Generally Available Release: 5.1.9) Standardized database driver Windows, Linux, Mac OS X, and Unix platforms.


The previous one should be the correct one (if I remind Rolling Eyes ). Several years ago I downloaded it and run the reference case in the upp distribution. You just need to add the path library in the setup panel to the include and lib tab. My DB was on a local WAMP server and it worked.
Please consider that not all provider give permission to work in remote with their DB.

Luigi
Re: mySql - how to use - what is needed? [message #34951 is a reply to message #34676] Mon, 19 December 2011 22:29 Go to previous message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
To add something to very helpful Luigi's comments, please find in the attached file, the information about the path configuration settled on my laptop to used MySql layer in my applications. Hope this will help you.

1- Bin
C:\Program Files\MySql\MySql Server 5.5\bin

2- Include files
C:\Program Files\MySql\MySql Server 5.5\include

3- Lib files
C:\Program Files\MySql\MySql Server 5.5\lib

Of course, this is true for Windows OS and depend on your own installation paths for MySql server.

Regards
Biobytes
Previous Topic: CanClose? Mechanism to prompt user to save edits
Next Topic: New class
Goto Forum:
  


Current Time: Wed Apr 24 12:43:39 CEST 2024

Total time taken to generate the page: 0.02421 seconds