Unable to delete character.

Results 1 to 4 of 4
  1. #1
    Account Upgraded | Title Enabled! Halcyon is offline
    MemberRank
    Mar 2011 Join Date
    1,102Posts

    Unable to delete character.

    I am having a small problem. For some reason, I am unable to delete my character because of of a error in my bat file that says:
    1-20-2013-5-55-a
    My client deletecharacter method is:
    PHP Code:
     public final int deleteCharacter(final int cid) {
            try {
                final 
    Connection con DatabaseConnection.getConnection();
                
    PreparedStatement ps con.prepareStatement("SELECT guildid, guildrank, familyid, name FROM characters WHERE id = ? AND accountid = ?");
                
    // delete pets
                
    ps con.prepareStatement("SELECT petid FROM inventoryitems WHERE characterid = ?");
                
    ps.setInt(1cid);
                
    ResultSet rs2 ps.executeQuery();
                while (
    rs2.next()) {
                        
    int petid rs2.getInt("petid");
                        if (
    petid > -1) {
                                
    MaplePet.deletePetById(petid);
                        }
                }
                
    rs2.close();
                
    ps.close();  
                
    ps.setInt(1cid);
                
    ps.setInt(2accId);
                
    ResultSet rs ps.executeQuery();
                if (!
    rs.next()) {
                    
    rs.close();
                    
    ps.close();
                    return 
    9;
                }
                if (
    rs.getInt("guildid") > 0) { // is in a guild when deleted
                    
    if (rs.getInt("guildrank") == 1) { //cant delete when leader
                        
    rs.close();
                        
    ps.close();
                        return 
    22;
                    }
                    
    World.Guild.deleteGuildCharacter(rs.getInt("guildid"), cid);
                }
                if (
    rs.getInt("familyid") > && World.Family.getFamily(rs.getInt("familyid")) != null) {
                    
    World.Family.getFamily(rs.getInt("familyid")).leaveFamily(cid);
                }
                
    rs.close();
                
    ps.close();

                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM characters WHERE id = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"UPDATE pokemon SET active = 0 WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM hiredmerch WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM mts_cart WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM mts_items WHERE characterid = ?"cid);
                
    //MapleCharacter.deleteWhereCharacterId(con, "DELETE FROM cheatlog WHERE characterid = ?", cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM mountdata WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM inventoryitems WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM famelog WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM famelog WHERE characterid_to = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM dueypackages WHERE RecieverId = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM wishlist WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM buddies WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM buddies WHERE buddyid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM keymap WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM trocklocations WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM regrocklocations WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM hyperrocklocations WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM savedlocations WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM skills WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM familiars WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM mountdata WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM skillmacros WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM trocklocations WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM queststatus WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM inventoryslot WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM extendedSlots WHERE characterid = ?"cid);
                return 
    0;
            } catch (
    Exception e) {
                
    FileoutputUtil.outputFileError(FileoutputUtil.PacketEx_Loge);
                
    e.printStackTrace();
            }
            return 
    10;
        } 
    I do not know what "com.mysql.jdbc.exceptions.jdbc4.MySqlNonTransientConnectionException: No operations allowed after statement closed." Means. :(
    This is the error I get while trying to delete my character in-game:
    Last edited by Lowsir; 21-01-13 at 12:02 AM.


  2. #2
    Account Upgraded | Title Enabled! Halcyon is offline
    MemberRank
    Mar 2011 Join Date
    1,102Posts

    Re: Unable to delete character.

    Bump.

  3. #3
    Account Upgraded | Title Enabled! Nmb1Gamer is offline
    MemberRank
    Apr 2009 Join Date
    Anime HeavenLocation
    383Posts

    Re: Unable to delete character.

    Try using this

    PHP Code:
     public final int deleteCharacter(final int cid) {
            try {
                final 
    Connection con DatabaseConnection.getConnection();
                
    PreparedStatement ps con.prepareStatement("SELECT guildid, guildrank, familyid, name FROM characters WHERE id = ? AND accountid = ?");
                
    ps.setInt(1cid);
                
    ps.setInt(2accId);
                
    ResultSet rs ps.executeQuery();
                if (!
    rs.next()) {
                    
    rs.close();
                    
    ps.close();
                    return 
    9;
                }
                if (
    rs.getInt("guildid") > 0) { // is in a guild when deleted
                    
    if (rs.getInt("guildrank") == 1) { //cant delete when leader
                        
    rs.close();
                        
    ps.close();
                        return 
    22;
                    }
                    
    World.Guild.deleteGuildCharacter(rs.getInt("guildid"), cid);
                }
                if (
    rs.getInt("familyid") > && World.Family.getFamily(rs.getInt("familyid")) != null) {
                    
    World.Family.getFamily(rs.getInt("familyid")).leaveFamily(cid);
                }
                
    rs.close();
                
    ps.close();

                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM characters WHERE id = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"UPDATE pokemon SET active = 0 WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM hiredmerch WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM mts_cart WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM mts_items WHERE characterid = ?"cid);
                
    //MapleCharacter.deleteWhereCharacterId(con, "DELETE FROM cheatlog WHERE characterid = ?", cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM mountdata WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM inventoryitems WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM famelog WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM famelog WHERE characterid_to = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM dueypackages WHERE RecieverId = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM wishlist WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM buddies WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM buddies WHERE buddyid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM keymap WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM trocklocations WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM regrocklocations WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM hyperrocklocations WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM savedlocations WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM skills WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM familiars WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM mountdata WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM skillmacros WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM trocklocations WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM queststatus WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM inventoryslot WHERE characterid = ?"cid);
                
    MapleCharacter.deleteWhereCharacterId(con"DELETE FROM extendedSlots WHERE characterid = ?"cid);
                return 
    0;
            } catch (
    Exception e) {
                
    FileoutputUtil.outputFileError(FileoutputUtil.PacketEx_Loge);
                
    e.printStackTrace();
            }
            return 
    10;
        } 

  4. #4
    Account Upgraded | Title Enabled! Dichotome is offline
    MemberRank
    Apr 2008 Join Date
    385Posts

    Re: Unable to delete character.

    Your transient error is caused by these lines, you have closed the preparedstatement, and then tried to use it.

    ps.close();
    ps.setInt(1, cid);





Advertisement