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 » U++ Library support » U++ SQL » MySql.cpp (MySqlSession::Connect)
MySql.cpp (MySqlSession::Connect) [message #4376] Thu, 03 August 2006 17:49 Go to next message
Ptomaine is currently offline  Ptomaine
Messages: 11
Registered: July 2006
Promising Member
Hi there!
It would be much more better to know an error if a connection failed. Here is the draft code to implement the task.

bool MySqlSession::Connect(const char *user, const char *password, const char *database,
                           const char *host, int port, const char *socket) {
	mysql = mysql_init((MYSQL*) 0);
	if(mysql && mysql_real_connect(mysql, sEmpNull(host), sEmpNull(user),
		                           sEmpNull(password), sEmpNull(database), port,
								   sEmpNull(socket), 0)) {
		Sql sql(*this);
		username = sql.Select("substring_index(USER(),'@',1)");
		return true;
	}

       errorstatement = mysql->net.last_error-2; //we must substract 2 to fix MySQL Server 5.0.19 bug.


        Close();
	return false;
}

[Updated on: Thu, 03 August 2006 17:53]

Report message to a moderator

Re: MySql.cpp (MySqlSession::Connect) [message #4398 is a reply to message #4376] Fri, 04 August 2006 22:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Looks like a good idea, however, any references to that error-2 problem?

Mirek
Re: MySql.cpp (MySqlSession::Connect) [message #4438 is a reply to message #4376] Mon, 07 August 2006 16:49 Go to previous messageGo to next message
Ptomaine is currently offline  Ptomaine
Messages: 11
Registered: July 2006
Promising Member
Sorry, that's not the mysql bug. This is related to UPP's libmySQL.a library.
Re: MySql.cpp (MySqlSession::Connect) [message #4439 is a reply to message #4438] Mon, 07 August 2006 17:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
So the .a shipped with U++ is flawed?

Frankly, I have picked that file somewhere on the web. I would be glad to replace it with the corrected version (any ideas?).

Mirek
Re: MySql.cpp (MySqlSession::Connect) [message #4499 is a reply to message #4439] Sat, 12 August 2006 11:13 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I still have this marked as unresolved problem. Anybody to help?

Mirek
Re: MySql.cpp (MySqlSession::Connect) [message #4531 is a reply to message #4376] Mon, 14 August 2006 17:19 Go to previous messageGo to next message
Ptomaine is currently offline  Ptomaine
Messages: 11
Registered: July 2006
Promising Member
Hi Mirek.

Why not to consider the "mysql++" library that is so powerful? There are things in the "mysql++" that are even more powerful than mysql C library and your wrapper classes together can provide (i.e. (SSQLS)).
Re: MySql.cpp (MySqlSession::Connect) [message #4535 is a reply to message #4531] Mon, 14 August 2006 18:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ptomaine wrote on Mon, 14 August 2006 11:19

Hi Mirek.

Why not to consider the "mysql++" library that is so powerful? There are things in the "mysql++" that are even more powerful than mysql C library and your wrapper classes together can provide (i.e. (SSQLS)).


Thats not even close. E.g. no SqlExp.

SSQLS in U++ is ".sch schema". Much more powerful.

Also, U++ Sql is designed to work with many RDBMs. Recent changes will even make possible platform independent SQL.

OTOH, if you like mysql++ more, simply go for it. There is no reason why you should not use external library with U++.

Means, issue is still unresolved. Could you please drop me a couple of words why there is "-2" and how we could fix that issue?

Mirek
Re: MySql.cpp (MySqlSession::Connect) [message #4536 is a reply to message #4376] Mon, 14 August 2006 19:00 Go to previous message
Ptomaine is currently offline  Ptomaine
Messages: 11
Registered: July 2006
Promising Member
Sorry, can't explain why, but it so.
Previous Topic: SqlArray Accept() Enables controls
Next Topic: build CppSQLite failed
Goto Forum:
  


Current Time: Sun Apr 28 22:51:14 CEST 2024

Total time taken to generate the page: 0.05030 seconds