|
|
Home » U++ Library support » U++ SQL » Sql(SqlSession& session) problem
Sql(SqlSession& session) problem [message #37300] |
Mon, 17 September 2012 23:09 |
|
koldo
Messages: 3402 Registered: August 2008
|
Senior Veteran |
|
|
Hello all
I have just recompiled from last svn and I have got this linking error:
error LNK2001: unresolved external symbol "public: __thiscall Upp::Sql::Sql(class Upp::SqlSession &)"
In Sqls.h, Sql(SqlSession& session); declaration appears.
I recognize that I am not an expert in sql so it would be great if somebody could know what to do.
Best regards
Iñaki
[Updated on: Mon, 17 September 2012 23:09] Report message to a moderator
|
|
|
Re: Sql(SqlSession& session) problem [message #37301 is a reply to message #37300] |
Tue, 18 September 2012 07:18 |
|
Similar problem here. Starting from 5366 linking of HomeBudget fails:
Quote: | /home/h/.upp/wd_out/HomeBudget/GCCMK.Blitz.Gui.Main.Shared.S se2/HomeBudget.o: In function `GuiMainFn_()':
HomeBudget.cpp:(.text._Z10GuiMainFn_v+0xf7): undefined reference to `Upp::Sql::Sql(Upp::SqlSession&)'
/home/h/.upp/wd_out/plugin/sqlite3/GCCMK.Blitz.Gui.Shared.Ss e2/Sqlite3upp.o: In function `Upp::Sqlite3Session::EnumViews(Upp::String)':
Sqlite3upp.cpp:(.text._ZN3Upp14Sqlite3Session9EnumViewsENS_6 StringE+0x4b): undefined reference to `Upp::Sql::Sql(Upp::SqlSession&)'
/home/h/.upp/wd_out/plugin/sqlite3/GCCMK.Blitz.Gui.Shared.Ss e2/Sqlite3upp.o: In function `Upp::Sqlite3Session::EnumTables(Upp::String)':
Sqlite3upp.cpp:(.text._ZN3Upp14Sqlite3Session10EnumTablesENS _6StringE+0x4b): undefined reference to `Upp::Sql::Sql(Upp::SqlSession&)'
/home/h/.upp/wd_out/plugin/sqlite3/GCCMK.Blitz.Gui.Shared.Ss e2/Sqlite3upp.o: In function `Upp::Sqlite3Session::EnumDatabases()':
Sqlite3upp.cpp:(.text._ZN3Upp14Sqlite3Session13EnumDatabases Ev+0x24): undefined reference to `Upp::Sql::Sql(Upp::SqlSession&)'
/home/h/.upp/wd_out/plugin/sqlite3/GCCMK.Blitz.Gui.Shared.Ss e2/Sqlite3upp.o: In function `Upp::Sqlite3Session::EnumColumns(Upp::String, Upp::String)':
Sqlite3upp.cpp:(.text._ZN3Upp14Sqlite3Session11EnumColumnsEN S_6StringES1_+0x54): undefined reference to `Upp::Sql::Sql(Upp::SqlSession&)'
/home/h/.upp/wd_out/Sql/GCCMK.Blitz.Gui.Shared.Sse2/$blitz.o :$blitz.cpp:(.text._ZN3Upp10SqlSession14GetSessionSqlREv+0x2 5): more undefined references to `Upp::Sql::Sql(Upp::SqlSession&)' follow
collect2: error: ld returned 1 exit status
|
Best regards,
Honza
|
|
|
|
|
|
Re: Sql(SqlSession& session) problem [message #37306 is a reply to message #37305] |
Tue, 18 September 2012 13:00 |
|
mirek wrote on Tue, 18 September 2012 11:47 | Sorry, my fault, was documenting Sql and SqlSession and for a moment, that seemed like a good idea (so that we do not need to explain existence of SqlSource, which is sort of relict of the past).
Should be now fixed.
|
I can confirm that 5371 is building OK again. Thanks Mirek.
Honza
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Sql(SqlSession& session) problem (SOLVED) [message #40321 is a reply to message #40320] |
Thu, 18 July 2013 18:37 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Hello, Danny.
pfsdanny wrote on Thu, 18 July 2013 15:24 | After rewrite the code, it works. So the following code that is ok in 4193 does not work in 5485.
Toggle source code
class c_db : public MySqlSession{
public:
typedef c_db CLASSNAME;
String username;
String password;
String database;
String host;
String collate;
String lockId;
int port;
bool connect(bool prompt=true);
void disconnect();
void copyFm(c_db db); <<--- this line cause error !
void copyFm(String xhost, String xdatabase, String xusername, String xpassword, String xcollate, int sport); <<-- change to this one and no problems !
bool getlock(String name);
bool releaselock();
c_db();
~c_db();
};
|
You are right, that after 4296 revision your previous code doesn't work, because of "Sql, SqlSession: operator= and copy constructors now private".
I think, you could rewrite your code as follows:
Toggle source code
#include <MySql/MySql.h>
using namespace Upp;
struct DBData {
String username;
String password;
String database;
String host;
String collate;
String lockId;
int port;
DBData() : port(3306) { }
DBData(const String& username, const String& password, const String& database, const String& host,
const String& collate, const String& lockId, int port = 3306) : username(username),
password(password), database(database), host(host), collate(collate), lockId(lockId), port(port) { }
};
class DBConnection {
protected:
MySqlSession session;
DBData data;
public:
// DBConnection() { }
DBConnection(const DBData& data) : data(data) { }
~DBConnection() { Disconnect(); ReleaseLock(); }
MySqlSession& GetSession() { return session; }
const DBData& GetData() { return data; }
void SetData(const DBData& d) { data = d; }
bool Connect(bool prompt = true);
void Disconnect();
bool GetLock(const String& name);
bool ReleaseLock();
};
// TODO: implement
bool DBConnection::Connect(bool prompt)
{
return true;
}
// TODO: implement
void DBConnection::Disconnect()
{
}
// TODO: implement
bool DBConnection::GetLock(const String& name)
{
return true;
}
// TODO: implement
bool DBConnection::ReleaseLock()
{
return true;
}
CONSOLE_APP_MAIN
{
DBData data("username", "password", "database", "host", "collate", "lockId");
DBConnection ctn(data);
if (!ctn.Connect())
return;
SQL = ctn.GetSession();
/* // Doing some query:
Sql sql;
sql * Select(SqlAll()).From(TABLE);
while(sql.Fetch()) { }
*/
}
where you will have DBData structure to avoid the need to copy each variable to c_db::copyFm method and no need to assign MySqlSession contents.
[Updated on: Thu, 18 July 2013 18:40] Report message to a moderator
|
|
|
Re: Sql(SqlSession& session) problem (SOLVED) [message #40326 is a reply to message #40321] |
Fri, 19 July 2013 15:57 |
pfsdanny
Messages: 26 Registered: December 2011 Location: Hong Kong
|
Promising Member |
|
|
Thanks.
Should you please explain these 2 lines. I don't understand what it means. I am new to C, thanks.
DBData() : port(3306) { }
DBData(const String& username, const String& password,
const String& database, const String& host,
const String& collate, const String& lockId, int port = 3306) :
username(username), password(password), database(database),
host(host), collate(collate), lockId(lockId), port(port) { }
|
|
|
Re: Sql(SqlSession& session) problem (SOLVED) [message #40328 is a reply to message #40326] |
Fri, 19 July 2013 19:25 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
pfsdanny wrote on Fri, 19 July 2013 15:57 | Should you please explain these 2 lines. I don't understand what it means. I am new to C, thanks.
DBData() : port(3306) { }
DBData(const String& username, const String& password,
const String& database, const String& host,
const String& collate, const String& lockId, int port = 3306) :
username(username), password(password), database(database),
host(host), collate(collate), lockId(lockId), port(port) { }
|
This feature is called C++ constructor initialization lists, where possible to do implicit assignments (when variables are created), instead of explicit assignments (afterwards):
DBData() { port = 3306; }
DBData(const String& username, const String& password, const String& database, const String& host,
const String& collate, const String& lockId, int port = 3306)
{
this->username = username; this->password = password; this->database = database;
this->host = host; this->collate = collate; this->lockId = lockId; this->port = port;
}
[Updated on: Fri, 19 July 2013 20:00] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Dec 02 23:44:11 CET 2024
Total time taken to generate the page: 0.02106 seconds
|
|
|