Examples of ThreadConnection


Examples of l2p.database.ThreadConnection

  private static Logger _log = Logger.getLogger(AutoBan.class.getName());

  public static boolean isBanned(int ObjectId)
  {
    boolean res = false;
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT MAX(endban) AS endban FROM bans WHERE obj_Id=? AND endban IS NOT NULL");
      statement.setInt(1, ObjectId);
      rset = statement.executeQuery();
      if(rset.next())
      {
        Long endban = rset.getLong("endban") * 1000L;
 
View Full Code Here

Examples of l2p.database.ThreadConnection

    return res;
  }

  public static void Banned(L2Player actor, int period, String msg, String GM)
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      int endban;
      if(period == -1)
      {
        endban = Integer.MAX_VALUE;
      }
      else if(period > 0)
      {
        Calendar end = Calendar.getInstance();
        end.add(Calendar.DAY_OF_MONTH, period);
        endban = (int) (end.getTimeInMillis() / 1000);
      }
      else
      {
        _log.warning("Negative ban period: " + period);
        return;
      }
      String date = new SimpleDateFormat("yy.MM.dd H:mm:ss").format(new Date());
      String enddate = new SimpleDateFormat("yy.MM.dd H:mm:ss").format(new Date(endban * 1000L));
      if(endban * 1000L <= Calendar.getInstance().getTimeInMillis())
      {
        _log.warning("Negative ban period | From " + date + " to " + enddate);
        return;
      }
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("INSERT INTO bans (account_name, obj_id, baned, unban, reason, GM, endban) VALUES(?,?,?,?,?,?,?)");
      statement.setString(1, actor.getAccountName());
      statement.setInt(2, actor.getObjectId());
      statement.setString(3, date);
      statement.setString(4, enddate);
      statement.setString(5, msg);
View Full Code Here

Examples of l2p.database.ThreadConnection

  public static boolean Banned(String actor, int acc_level, int period, String msg, String GM)
  {
    boolean res;
    int obj_id = Util.GetCharIDbyName(actor);
    res = obj_id > 0;
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    if(res)
    {
      try
      {
        con = L2DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE obj_Id=?");
        statement.setInt(1, acc_level);
        statement.setInt(2, obj_id);
        statement.executeUpdate();
        DatabaseUtils.closeStatement(statement);
        if(acc_level < 0)
        {
          int endban;
          if(period == -1)
          {
            endban = Integer.MAX_VALUE;
          }
          else if(period > 0)
          {
            Calendar end = Calendar.getInstance();
            end.add(Calendar.DAY_OF_MONTH, period);
            endban = (int) (end.getTimeInMillis() / 1000);
          }
          else
          {
            _log.warning("Negative ban period: " + period);
            return false;
          }
          String date = new SimpleDateFormat("yy.MM.dd H:mm:ss").format(new Date());
          String enddate = new SimpleDateFormat("yy.MM.dd H:mm:ss").format(new Date(endban * 1000L));
          if(endban * 1000L <= Calendar.getInstance().getTimeInMillis())
          {
            _log.warning("Negative ban period | From " + date + " to " + enddate);
            return false;
          }
          statement = con.prepareStatement("INSERT INTO bans (obj_id, baned, unban, reason, GM, endban) VALUES(?,?,?,?,?,?)");
          statement.setInt(1, obj_id);
          statement.setString(2, date);
          statement.setString(3, enddate);
          statement.setString(4, msg);
          statement.setString(5, GM);
          statement.setLong(6, endban);
          statement.execute();
        }
        else
        {
          statement = con.prepareStatement("DELETE FROM bans WHERE obj_id=?");
          statement.setInt(1, obj_id);
          statement.execute();
        }
      }
      catch(Exception e)
View Full Code Here

Examples of l2p.database.ThreadConnection

    return res;
  }

  public static void Karma(L2Player actor, int karma, String msg, String GM)
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      String date = new SimpleDateFormat("yy.MM.dd H:mm:ss").format(new Date());
      msg = "Add karma(" + karma + ") " + msg;
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("INSERT INTO bans (account_name, obj_id, baned, reason, GM) VALUES(?,?,?,?,?)");
      statement.setString(1, actor.getAccountName());
      statement.setInt(2, actor.getObjectId());
      statement.setString(3, date);
      statement.setString(4, msg);
      statement.setString(5, GM);
View Full Code Here

Examples of l2p.database.ThreadConnection

  public static boolean Karma(String actor, int karma, String msg, String GM)
  {
    boolean res;
    int obj_id = Util.GetCharIDbyName(actor);
    res = obj_id > 0;
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    if(res)
    {
      try
      {
        con = L2DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("update characters set karma=karma + ? where obj_Id=?");
        statement.setInt(1, karma);
        statement.setInt(2, obj_id);
        statement.execute();
        DatabaseUtils.closeStatement(statement);
        String date = new SimpleDateFormat("yy.MM.dd H:mm:ss").format(new Date());
        msg = "Add karma(" + karma + ") " + msg;
        statement = con.prepareStatement("INSERT INTO bans (obj_id, baned, reason, GM) VALUES(?,?,?,?)");
        statement.setInt(1, obj_id);
        statement.setString(2, date);
        statement.setString(3, msg);
        statement.setString(4, GM);
        statement.execute();
View Full Code Here

Examples of l2p.database.ThreadConnection

    if(obj_id == 0)
    {
      return false;
    }
    L2Player plyr = L2World.getPlayer(actor);
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    if(plyr != null)
    {
      plyr.sendMessage(new CustomMessage("l2p.Util.AutoBan.ChatBan", actor).addString(GM).addNumber(period));
      plyr.updateNoChannel(NoChannel);
    }
    else
    {
      try
      {
        con = L2DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("UPDATE characters SET nochannel = ? WHERE obj_Id=?");
        statement.setLong(1, NoChannel > 0 ? NoChannel / 1000 : NoChannel);
        statement.setInt(2, obj_id);
        statement.executeUpdate();
      }
      catch(Exception e)
View Full Code Here

Examples of l2p.database.ThreadConnection

    int obj_id = Util.GetCharIDbyName(actor);
    if(obj_id == 0)
    {
      return false;
    }
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    if(plyr != null)
    {
      plyr.sendMessage(new CustomMessage("l2p.Util.AutoBan.ChatUnBan", actor).addString(GM));
      plyr.updateNoChannel(0);
    }
    else
    {
      try
      {
        con = L2DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("UPDATE characters SET nochannel = ? WHERE obj_Id=?");
        statement.setLong(1, 0);
        statement.setInt(2, obj_id);
        statement.executeUpdate();
      }
      catch(Exception e)
View Full Code Here

Examples of l2p.database.ThreadConnection

  }

  public static int GetCharIDbyName(String name)
  {
    int res = 0;
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT obj_Id FROM characters WHERE char_name=? LIMIT 1");
      statement.setString(1, name);
      rset = statement.executeQuery();
      if(rset.next())
      {
        res = rset.getInt("obj_Id");
View Full Code Here

Examples of l2p.database.ThreadConnection

  }

  public static String getCharNameByIdD(int id)
  {
    String name = "";
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT char_name FROM characters WHERE obj_Id=? LIMIT 1");
      statement.setInt(1, id);
      rset = statement.executeQuery();
      if(rset.next())
      {
        name = rset.getString("char_name");
View Full Code Here

Examples of l2p.database.ThreadConnection

    return heading;
  }

  public static boolean isCharNameAvail(String name)
  {
    ThreadConnection con = null;
    FiltredPreparedStatement st = null;
    ResultSet rs = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      st = con.prepareStatement("SELECT char_name FROM characters WHERE char_name LIKE ?");
      st.setString(1, name);
      rs = st.executeQuery();
      return !rs.next();
    }
    catch(Exception e)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.