PreparedStatementinvalidateAccounts=connection.prepareStatement("INSERT IGNORE INTO login_cachelist (`UID`) SELECT `UID` from `obj_account` WHERE `discordAccount` = ?")){
StringqueryString="INSERT IGNORE INTO login_cachelist (`UID`) SELECT `UID` from `obj_account` WHERE `discordAccount` = ?";
PreparedStatementstatement=localConnection.prepareStatement(queryString,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);// Make this an updatable result set as we'll reset the dirty flag as we go along
PreparedStatementstatement=localConnection.prepareStatement(queryString,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);// Make this an updatable result set as we'll reset the dirty flag as we go along
ResultSetrs=statement.executeQuery()){
ResultSetrs=statement.executeQuery()){
@ -338,7 +339,7 @@ public class BaneRecord extends DataRecord {
PreparedStatementstatement=localConnection.prepareStatement(queryString,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);// Make this an updatable result set as we'll reset the dirty flag as we go along
PreparedStatementstatement=localConnection.prepareStatement(queryString,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);// Make this an updatable result set as we'll reset the dirty flag as we go along
ResultSetrs=statement.executeQuery()){
ResultSetrs=statement.executeQuery()){
@ -263,7 +264,7 @@ public class CharacterRecord extends DataRecord {
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT b.* FROM `static_rune_baseclass` b, `static_rune_racebaseclass` r WHERE b.`ID` = r.`BaseClassID` && r.`RaceID` = ?")){
preparedStatement.setInt(1,id);
ResultSetrs=preparedStatement.executeQuery();
baseClasses=getObjectsFromRs(rs,20);
}catch(SQLExceptione){
Logger.error(e);
}
returnbaseClasses;
}
}
publicArrayList<BaseClass>GET_ALL_BASE_CLASSES(){
publicArrayList<BaseClass>GET_ALL_BASE_CLASSES(){
prepareCallable("SELECT * FROM `static_rune_baseclass`;");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `accountID`, `characterID`, `machineID` FROM `dyn_session` WHERE `secretKey`=?")){
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `dyn_character_power` SET `PowersBaseToken`=?, `CharacterID`=?, `trains`=? WHERE `UID`=?")){
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `dyn_character_skill` SET `skillsBaseID`=?, `CharacterID`=?, `trains`=? WHERE `UID`=?")){
prepareCallable("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` WHERE `object`.`parent`=?;");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` WHERE `object`.`parent`=?;")){
prepareCallable("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` WHERE `object`.`UID`=?;");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` WHERE `object`.`UID`=?;")){
// prepareCallable("SELECT * FROM `obj_character`, `dyn_guild_banishlist` WHERE `obj_character.char_isActive` = 1 AND `dyn_guild_banishlist.CharacterID` = `obj_character.UID` AND `obj_character.GuildID`=?");
//prepareCallable("SELECT * FROM `obj_character` `,` `dyn_guild_banishlist` WHERE obj_character.char_isActive = 1 AND dyn_guild_banishlist.CharacterID = obj_character.UID AND dyn_guild_banishlist.GuildID = ?");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT g.* FROM `obj_guild` g, `dyn_character_guildhistory` l WHERE g.`UID` = l.`GuildID` && l.`CharacterID` = ?")){
// prepareCallable("SELECT * FROM `obj_character`, `dyn_guild_banishlist` WHERE `obj_character.char_isActive` = 1 AND `dyn_guild_banishlist.CharacterID` = `obj_character.UID` AND `obj_character.GuildID`=?");
//prepareCallable("SELECT * FROM `obj_character` `,` `dyn_guild_banishlist` WHERE obj_character.char_isActive = 1 AND dyn_guild_banishlist.CharacterID = obj_character.UID AND dyn_guild_banishlist.GuildID = ?");
prepareCallable("SELECT `obj_guild`.*, `object`.`parent` FROM `obj_guild` INNER JOIN `object` ON `object`.`UID` = `obj_guild`.`UID` WHERE `object`.`UID`=?");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_guild`.*, `object`.`parent` FROM `obj_guild` INNER JOIN `object` ON `object`.`UID` = `obj_guild`.`UID` WHERE `object`.`UID`=?")){
preparedStatement.setLong(1,id);
ResultSetrs=preparedStatement.executeQuery();
guild=(Guild)getObjectFromRs(rs);
}catch(SQLExceptione){
Logger.error(e);
}
returnguild;
}
}
publicArrayList<Guild>GET_ALL_GUILDS(){
publicArrayList<Guild>GET_ALL_GUILDS(){
prepareCallable("SELECT `obj_guild`.*, `object`.`parent` FROM `obj_guild` INNER JOIN `object` ON `object`.`UID` = `obj_guild`.`UID`");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `guild_isInnerCouncil`, `guild_isTaxCollector`, `guild_isRecruiter` FROM `obj_character` WHERE `UID`=? && `guildUID`=?")){
ResultSetrs=executeQuery();
preparedStatement.setLong(1,target);
preparedStatement.setLong(2,guildId);
ResultSetrs=preparedStatement.executeQuery();
//If the first query had no results, neither will the second
//If the first query had no results, neither will the second
prepareCallable("UPDATE `dyn_guild_allianceenemylist` SET `isAlliance` = ? WHERE `GuildID`=? AND `OtherGuildID`=?");
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `dyn_guild_allianceenemylist` SET `isRecommended` = ? WHERE `GuildID`=? AND `OtherGuildID`=?")){
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `dyn_guild_allianceenemylist` SET `isAlliance` = ? WHERE `GuildID`=? AND `OtherGuildID`=?")){
prepareCallable("SELECT * FROM `dyn_guild_allianceenemylist` WHERE `GuildID` = ?");
preparedStatement.setLong(1,sourceGuildID);
setInt(1,guild.getObjectUUID());
preparedStatement.setLong(2,targetGuildID);
try{
return(preparedStatement.executeUpdate()>0);
ResultSetrs=executeQuery();
//shrines cached in rs for easy cache on creation.
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `dyn_guild_allianceenemylist` SET `isRecommended` = ?, `isAlliance` = ? WHERE `GuildID`=? AND `OtherGuildID`=?")){
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=? && `obj_item`.`item_container`='equip';")){
preparedStatement.setLong(1,targetId);
ResultSetrs=preparedStatement.executeQuery();
itemList=getObjectsFromRs(rs,10);
}catch(SQLExceptione){
Logger.error(e);
returnnull;
}
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`UID`=?;");
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=? AND `obj_item`.`item_itembaseID`=?;");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`UID`=?;")){
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?;");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?;")){
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?;")){
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?");
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE (`object`.`parent`=? OR `object`.`parent`=?)");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?")){
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems` = CASE WHEN `UID`=? THEN ? WHEN `UID`=? THEN ? END WHERE `UID` IN (?, ?);")){
intnewFromAmt=from.getNumOfItems()-amt;
intnewFromAmt=from.getNumOfItems()-amt;
intnewToAmt=to.getNumOfItems()+amt;
intnewToAmt=to.getNumOfItems()+amt;
prepareCallable("UPDATE `obj_item` SET `item_numberOfItems` = CASE WHEN `UID`=? THEN ? WHEN `UID`=? THEN ? END WHERE `UID` IN (?, ?);");
prepareCallable("UPDATE `obj_item` LEFT JOIN `object` ON `object`.`UID` = `obj_item`.`UID` SET `object`.`parent`=NULL, `obj_item`.`item_container`='none' WHERE `object`.`UID`=?;");
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `obj_item` LEFT JOIN `object` ON `object`.`UID` = `obj_item`.`UID` SET `object`.`parent`=NULL, `obj_item`.`item_container`='none' WHERE `object`.`UID`=?;")){
prepareCallable("SELECT `obj_item`.*, `object`.`parent` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=? AND `obj_item`.`item_container` =?");
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `obj_item` SET `item_durabilityCurrent`=? WHERE `UID`=? AND `item_durabilityCurrent`=?")){
prepareCallable("UPDATE `obj_item` SET `item_itembaseID`=?, `item_chargesRemaining`=?, `item_durabilityCurrent`=?, `item_durabilityMax`=?, `item_numberOfItems`=? WHERE `UID`=?");
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `obj_item` SET `item_container` = ? WHERE `UID` = ? AND `item_container` = 'forge';")){
prepareCallable("UPDATE `obj_item` SET `item_numberOfItems` = CASE WHEN `UID`=? AND `item_numberOfItems`=? THEN ? WHEN `UID`=? AND `item_numberOfItems`=? THEN ? END WHERE `UID` IN (?, ?);");
prepareCallable("SELECT `obj_character`.*, `object`.`parent` FROM `object` INNER JOIN `obj_character` ON `obj_character`.`UID` = `object`.`UID` WHERE `obj_character`.`char_isActive`='1';");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_character`.*, `object`.`parent` FROM `object` INNER JOIN `obj_character` ON `obj_character`.`UID` = `object`.`UID` WHERE `obj_character`.`char_isActive`='1';")){
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `char_firstname` FROM `obj_character` WHERE `char_isActive`=1 && `char_firstname`=?")){
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `obj_character` SET `char_firstname`=?, `char_lastname`=? WHERE `char_firstname`=? AND `char_isActive`='1'")){
setString(3,oldFirstName);
return(executeUpdate()!=0);
preparedStatement.setString(1,newFirstName);
preparedStatement.setString(2,newLastName);
preparedStatement.setString(3,oldFirstName);
return(preparedStatement.executeUpdate()>0);
}catch(SQLExceptione){
Logger.error(e);
}
returnfalse;
}
}
publicbooleanSET_DELETED(finalPlayerCharacterpc){
publicbooleanSET_DELETED(finalPlayerCharacterpc){
prepareCallable("UPDATE `obj_character` SET `char_isActive`=? WHERE `UID` = ?");
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `obj_character` SET `char_strMod`=?, `char_dexMod`=?, `char_conMod`=?, `char_intMod`=?, `char_spiMod`=? WHERE `UID`=?")){
prepareCallable("SELECT `obj_shrine`.*, `object`.`parent`, `object`.`type` FROM `object` LEFT JOIN `obj_shrine` ON `object`.`UID` = `obj_shrine`.`UID` WHERE `object`.`type` = 'shrine';");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_shrine`.*, `object`.`parent`, `object`.`type` FROM `object` LEFT JOIN `obj_shrine` ON `object`.`UID` = `obj_shrine`.`UID` WHERE `object`.`type` = 'shrine';")){
try{
ResultSetrs=preparedStatement.executeQuery();
ResultSetrs=executeQuery();
//shrines cached in rs for easy cache on creation.
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT IDString, type FROM static_power_failcondition where powerOrEffect = 'Power'")){
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_warehouse`.*, `object`.`parent`, `object`.`type` FROM `object` LEFT JOIN `obj_warehouse` ON `object`.`UID` = `obj_warehouse`.`UID` WHERE `object`.`type` = 'warehouse';")){
prepareCallable("SELECT `obj_warehouse`.*, `object`.`parent`, `object`.`type` FROM `object` LEFT JOIN `obj_warehouse` ON `object`.`UID` = `obj_warehouse`.`UID` WHERE `object`.`type` = 'warehouse';");
Logger.warn("Warning! WorldServerMap with ID "+zone.getObjectUUID()+" has a loadnum of 0 (player city) and no city linked. This will probably crash the client!");
Logger.warn("Warning! WorldServerMap with ID "+zone.getObjectUUID()+" has a loadnum of 0 (player city) and no city linked. This will probably crash the client!");
PreparedStatementstatement=connection.prepareStatement("SELECT * from `object` where `type` = 'item' AND `parent` IS NULL",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
PreparedStatementstatement=connection.prepareStatement("SELECT * from `object` where `type` = 'item' AND `parent` IS NULL",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);