General Discussion (#1) - SQl help for bot (#14) - Message List
this is my code for sql. Problem is bot doesn't write to the sql database. I'm sure its a dumb error because I haven't programmed something in a few years. That query isnt done yet. I still need to add to make it update if theres a duplicate key. Any ideas?
public void handleEvent(PlayerEntered event)
{
String name = event.getPlayerName(); String squad = event.getSquadName(); short wins = event.getWins(); short losses = event.getLosses(); int kpoints = event.getKillPoints(); int fpoints = event.getFlagPoints();
String query = "INSERT INTO stat (name, squad, wins, losses, kpoints, fpoints) VALUES('"+name+"','"+squad+"','"+wins+"','"+losses+"','"+kpoints+"','"+fpoints+"') ; try {
m_botAction.SQLQuery(mySQLHost, query);
} catch (SQLException e) { e.printStackTrace();
}
}
-
Message #18
Do you get a stacktrace when you try?
If not, are you sure the event is even fired? (Have you requested the event from the EventRequester?)Maverick12/26/07 16:31:07 -
Message #19
I don't get a stacktrace and I have the event requested from the EventRequester.
CRe12/26/07 18:03:52 -
Message #20
You're missing an end quotation at the end of your String query.
String query = "INSERT INTO stat (name, squad, wins, losses, kpoints, fpoints) VALUES('"+name+"','"+squad+"','"+wins+"','"+losses+"','"+kpoints+"','"+fpoints+"') ";
I suppose I'll ask the obvious questions… do you have your sql.cfg setup properly with Connection Count being 1+ and your database's information filled in? Does your database contain a table named stat with the appropriate values etc.?
milosh12/26/07 20:37:31 -
Message #21
Quotation was there in my src. Heres a copy of my sql.cfg with pass blanked out and I have a table named stat with the appropriate values.
[General] RetryCount=3 ConnectionCount=1
[Connection 1] Name1=db229467413 Driver1=com.mysql.jdbc.Driver Login1=dbo229467413 Password1=——- DataBase1=db229467413 Server1=db1302.perfora.net Port1=3306 MinPoolSize1=0 MaxPoolSize1=10 WaitIfBusy1=1
CRe12/27/07 08:00:47 -
Message #24
When running the bot you must get some sort of error why this isn't working. Check the console window or the exception.log .
Maverick12/28/07 01:22:32 -
Message #25
No error in console window or exception.log.
CRe12/28/07 07:47:36 -
Message #26
Heh….
use m_botAction.SQLQueryAndClose(mySQLHost, query);
milosh12/28/07 10:22:17 -
Message #27
The method SQLQueryAndClose(String, String) is undefined for the type BotAction
CRe12/28/07 12:32:39 -
Message #28
He's using an older version TWCore, milosh.
Probably revision 1320 from the Download page.Maverick12/28/07 15:39:03 -
Message #29
Work around it…
use the following…
m_botAction.SQLClose(m_botAction.SQLQuery(mySQLHost, query));
milosh12/29/07 08:14:46 -
Message #30
The method SQLClose(ResultSet) is also undefined for the type BotAction. Any way I can get a more updated version?
CRe12/30/07 12:16:23 -
Message #31
See the wiki:Download page
Maverick12/30/07 12:51:40
