Home » Renegade Discussions » Mod Forum » MySQL with SSGM?
MySQL with SSGM? [message #432883] |
Fri, 16 July 2010 17:48 |
|
TechnoBulldog
Messages: 15 Registered: May 2010 Location: Texas
Karma:
|
Recruit |
|
|
It's sad that the only reason I'm posting is because I have a problem.
I'm new to making c++ SSGM plugins and MySQL with c++. I'm trying to make a simple "!postnote" command that will add a player's name and message to a table in the database (I know someone is going to say "Why don't you use fstream or another io function?" It's because I want to experiment with databases). At the moment, I've been able to make it connect, but whenever it tries to execute a query, the server crashes. It doesn't seem to have any trouble with connecting to MySQL, I mean, if I use the correct username and password, it works fine, and when it's the incorrect username and password, it tells me there was an error. I only seem to have a problem when I try to execute a query, at which point, the server crashes without adding anything to the database. I also get 7 warnings when I compile it, all coming from "cppconn/exception.h". I made a simple console application using the same stuff and it worked fine.
I suppose my first question would be, is it possible to have MySQL in an SSGM plugin?
Second would be, is there an obvious reason it is crashing my server?
Toggle Spoiler
It is the same as the example plugin, except for the following changes.
Notes: I changed the "Treat Warnings As Errors" to no (/wx I think) and I removed /analyze because it was causing a warning. I'm using this for the MySQL client library and this for the c++ connector.
Compiler: MSVC++ 2008 Express
Linked Libraries: mysqlcppconn.lib libmysql.lib
Server Folder DLLs: libmysql.dll MSVCP90.dll MSVCR90.dll mysqlcppconn.dll
Edited Source:
Toggle Spoiler
class PostNoteCommand : public ChatCommandClass
{
void Triggered(int ID,const TokenClass &Text,int ChatType)
{
/* Text is a tokenized version of the command paramter.
Text[1] would get the first word after the command.
Text[0] would get everything after the command.
Text(3) would get word 3 and everything after it.
Text(2,4) would get words 2 through 4.
*/
try
{
std::string pName = Get_Player_Name_By_ID(ID);
con = driver->connect("tcp://127.0.0.1:3306", "admin", "****word");
// I'm not entirely sure what this does, but I'm guessing that it selects the database.
con->setSchema("renegade");
statement = con->createStatement();
std::string query = StrFormat("INSERT INTO messages(name, message) VALUES('%s', '%s')", pName, Text[0]);
// Will cause server to crash.
//statement->execute(query);
// Will cause server to crash.
//statement->executeQuery("INSERT INTO messages(name, message) VALUES('tester5', 'testing value')");
}
catch(sql::SQLException &e)
{
Console_Input("msg MySQL query failure...");
// error C2664: 'Console_Input' : cannot convert parameter 1 from 'std::string' to 'const char *'
// No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
//Console_Input(StrFormat("ppage %d MySQL Error: %%", ID, e.what()));
}
delete statement;
delete con;
}
};
ChatCommandRegistrant<PostNoteCommand> PostNoteCommandReg("!postnote", CHATTYPE_ALL, 1, GAMEMODE_ALL);
Build Output Window:
Toggle Spoiler
Compiling...
plugin.cpp
C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(47) : warning C4251: 'sql::SQLException::sql_state' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'sql::SQLException'
with
[
_Elem=char,
_Traits=std::char_traits,
_Ax=std::allocator
]
C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(79) : warning C4512: 'sql::SQLException' : assignment operator could not be generated
C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(41) : see declaration of 'sql::SQLException'
C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(88) : warning C4512: 'sql::MethodNotImplementedException' : assignment operator could not be generated
C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(81) : see declaration of 'sql::MethodNotImplementedException'
C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(97) : warning C4512: 'sql::InvalidArgumentException' : assignment operator could not be generated
C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(90) : see declaration of 'sql::InvalidArgumentException'
C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(106) : warning C4512: 'sql::InvalidInstanceException' : assignment operator could not be generated
C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(99) : see declaration of 'sql::InvalidInstanceException'
C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(116) : warning C4512: 'sql::NonScrollableException' : assignment operator could not be generated
C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(109) : see declaration of 'sql::NonScrollableException'
.\plugin.cpp(97) : warning C4101: 'e' : unreferenced local variable
Linking...
Searching libraries
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib:
Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib:
Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib:
Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib:
Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib:
Finished searching libraries
Creating library .\bin/scripts.lib and object .\bin/scripts.exp
Searching libraries
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib:
Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib:
Finished searching libraries
Generating code
Finished generating code
Searching libraries
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib:
Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib:
Finished searching libraries
Searching libraries
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib:
Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib:
Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib:
Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib:
Finished searching libraries
Embedding manifest...
Creating browse information file...
Microsoft Browse Information Maintenance Utility Version 9.00.30729
Copyright (C) Microsoft Corporation. All rights reserved.
If I've made a stupid mistake somewhere, please point it out. If you think you might be able to help, but I left something out, let me know and I'll try to post the info. This is bugging me a lot haha. I also have a bad feeling this is the wrong place to post this...
Cloud-Zone Gaming. Check it out.
^^ Awesome right?
|
|
|
Goto Forum:
Current Time: Sun Nov 24 15:15:56 MST 2024
Total time taken to generate the page: 0.00855 seconds
|