Example #1
1
  public boolean savePassword(String password) {
    if (passwordExist()) {
      _log.warning(
          "[SecondaryPasswordAuth]" + _activeClient.getAccountName() + " forced savePassword");
      _activeClient.closeNow();
      return false;
    }

    if (!validatePassword(password)) {
      _activeClient.sendPacket(new Ex2ndPasswordAck(0, Ex2ndPasswordAck.WRONG_PATTERN));
      return false;
    }

    password = cryptPassword(password);

    try (Connection con = DatabaseFactory.getInstance().getConnection();
        PreparedStatement statement = con.prepareStatement(INSERT_PASSWORD)) {
      statement.setString(1, _activeClient.getAccountName());
      statement.setString(2, VAR_PWD);
      statement.setString(3, password);
      statement.execute();
    } catch (Exception e) {
      _log.log(Level.SEVERE, "Error while writing password.", e);
      return false;
    }
    _password = password;
    return true;
  }
  public void deleteAllItem() {

    if (dbe.FineDBExist()) {

      try {
        Class.forName("org.sqlite.JDBC");
        c = DriverManager.getConnection("jdbc:sqlite:c:/LibMgtSys/Fine.db");
        c.setAutoCommit(false);

        System.out.println("Opened Fine database successfully from DeleteFromDB  delete allll ");

        stmt = c.createStatement();
        String sql = "DELETE FROM FineTab";

        PreparedStatement pst = c.prepareStatement(sql);

        pst.executeUpdate();
        c.commit();

        stmt.close();
        c.close();
      } catch (Exception e) {
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
        System.exit(0);
      }

      System.out.println("All Data Deleted successfully");
      //   JOptionPane.showMessageDialog(null, " ALL Item Successfully Deleted.", "Delete Option: ",
      // JOptionPane.INFORMATION_MESSAGE);

    } else {
      //  JOptionPane.showMessageDialog(null, "sorry.. no database existed..", "Error..",
      // JOptionPane.ERROR_MESSAGE);
    }
  }
  /** Creates new form SessionLog */
  public SessionLog() {
    initComponents();

    try {
      Connection con = DBConnection.getConnection();
      String query = "select * from user_session where user_id=?";
      PreparedStatement psmt = con.prepareStatement(query);
      psmt.setString(1, "ababab");
      ResultSet rs = psmt.executeQuery();
      ResultSetMetaData rsmd;
      rsmd = rs.getMetaData();
      Vector column = new Vector();
      int count = rsmd.getColumnCount();
      DefaultTableModel dtm = new DefaultTableModel();
      for (int i = 1; i <= count; i++) {
        column.addElement(rsmd.getColumnName(i));
      }
      dtm.setColumnIdentifiers(column);
      while (rs.next()) {
        Vector row = new Vector();
        for (int i = 1; i <= count; i++) {
          row.addElement(rs.getString(i));
        }
        dtm.addRow(row);
      }
      jTable1.setModel(dtm);

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
 public boolean isValidParty(PartyLovVO partyLovVO) throws Exception {
   boolean validParty = false;
   Connection connection = null;
   StringBuilder finalQry = new StringBuilder();
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   QueryFields fields = null;
   String whereCond = "";
   try {
     fields = new QueryFields();
     fields.put("BP.DCS_STATUS", "1");
     fields.put("PR.DCS_CODE", partyLovVO.getPartyRole());
     fields.put("BP.DCS_CODE", partyLovVO.getPartyId());
     if (!StringUtility.isNullEmpty(partyLovVO.getRelatedParty())) {
       fields.put("BP.DCS_CODE", partyLovVO.getRelatedParty());
       fields.put("PR.DCS_CODE", partyLovVO.getRelationShipType());
     }
     whereCond = " AND " + QueryBuilderUtil.buildWhereCond(fields);
     finalQry.append(PartyLovQueries.validatePartyIdQry).append(whereCond);
     connection = getConnection();
     pstmt = connection.prepareStatement(finalQry.toString());
     rs = pstmt.executeQuery();
     if (rs.next()) {
       if (rs.getInt(1) > 0) {
         validParty = true;
       } else {
         validParty = false;
       }
     }
   } finally {
     ConnectionUtil.closeConnection(connection, pstmt, rs);
   }
   return validParty;
 }
Example #5
1
 public void updateTravellerCount(int id) {
   // how many travellers are in the TARDIS?
   Statement statement = null;
   ResultSet rsCount = null;
   try {
     Connection connection = service.getConnection();
     statement = connection.createStatement();
     String queryCount = "SELECT COUNT (*) AS count FROM travellers WHERE tardis_id = " + id;
     rsCount = statement.executeQuery(queryCount);
     if (rsCount.next()) {
       int count = rsCount.getInt("count");
       plugin.trackTravellers.put(id, count);
     }
     rsCount.close();
     statement.close();
   } catch (SQLException e) {
     plugin.console.sendMessage(plugin.pluginName + " /TARDIS travel to location Error: " + e);
   } finally {
     try {
       rsCount.close();
     } catch (Exception e) {
     }
     try {
       statement.close();
     } catch (Exception e) {
     }
   }
 }
  /**
   * Check the autoCommit and Transaction Isolation levels of the DataSource.
   *
   * <p>If autoCommit is true this could be a real problem.
   *
   * <p>If the Isolation level is not READ_COMMITED then optimistic concurrency checking may not
   * work as expected.
   */
  private boolean checkDataSource(ServerConfig serverConfig) {

    if (serverConfig.getDataSource() == null) {
      if (serverConfig.getDataSourceConfig().isOffline()) {
        // this is ok - offline DDL generation etc
        return false;
      }
      throw new RuntimeException("DataSource not set?");
    }

    Connection c = null;
    try {
      c = serverConfig.getDataSource().getConnection();

      if (c.getAutoCommit()) {
        String m = "DataSource [" + serverConfig.getName() + "] has autoCommit defaulting to true!";
        logger.warning(m);
      }

      return true;

    } catch (SQLException ex) {
      throw new PersistenceException(ex);

    } finally {
      if (c != null) {
        try {
          c.close();
        } catch (SQLException ex) {
          logger.log(Level.SEVERE, null, ex);
        }
      }
    }
  }
Example #7
1
  public void eliminarConfiguracion(int usuario) throws DAOException {
    log.info("eliminarConfiguracion(int usuario)");
    Connection cons = null;
    PreparedStatement stmt = null;
    try {
      String query = "DELETE FROM cv_servicio_usuario WHERE IDUSUARIO=?";
      cons = dataSource.getConnection();
      stmt = cons.prepareStatement(query);
      stmt.setInt(1, usuario);
      stmt.executeUpdate();

      query =
          "insert into cv_servicio_usuario(idusuario,idservicio,columna,posicion,visible,estado) "
              + "select ?,idservicio,columna,posicion,usuario_visible,usuario_estado "
              + "from cv_servicio_maestro";
      stmt = cons.prepareStatement(query);
      stmt.setInt(1, usuario);
      stmt.executeUpdate();
    } catch (SQLException e) {
      log.info(e.toString());
      throw new DAOException(e.toString());
    } catch (Exception e) {
      log.info(e.toString());
      throw new DAOException(e.toString());
    } finally {
      closeStatement(stmt);
      closeConnection(cons);
    }
  }
 public String getONT() {
   Connection con;
   String ontid = null;
   String JsonStr = "{\"ont\": [";
   try {
     con = DataSource.getConnection();
     PreparedStatement pst = con.prepareStatement("select ont_id from ont");
     ResultSet rs = pst.executeQuery();
     int flag = 1;
     while (rs.next()) {
       flag = 0;
       ontid = rs.getString("ont_id");
       JsonStr += "{\"ont_id\":\"" + ontid + "\"},";
     }
     if (flag == 1) {
       JsonStr += ",";
     }
     int len = JsonStr.length();
     JsonStr = JsonStr.substring(0, len - 1);
     JsonStr += "],";
   } catch (SQLException | ClassNotFoundException e) {
     System.out.println("error connection to the database getponids" + e.getMessage());
     return "";
   }
   System.out.println(JsonStr);
   DataSource.returnConnection(con);
   return JsonStr;
 }
 public String getKnownShipperDetails(String locationCode, String shipperId) {
   Connection connection = null;
   CallableStatement cStmt = null;
   ResultSet rs = null;
   String Code = null;
   try {
     connection = getConnection();
     cStmt = connection.prepareCall("{? = call ETRANS_UTIL.GETKNOWNSHIPPERSTATUS(?,?,?) }");
     cStmt.setString(2, locationCode);
     cStmt.setString(3, shipperId);
     cStmt.setString(4, "OPR");
     cStmt.registerOutParameter(1, java.sql.Types.VARCHAR);
     cStmt.execute();
     Code = cStmt.getString(1);
   } catch (SQLException e) {
     e.printStackTrace();
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     try {
       ConnectionUtil.closeConnection(connection, cStmt, rs);
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   return Code;
 }
 public String getCollectShipmentForParty(String partyId) throws Exception {
   Connection connection = null;
   PreparedStatement pStmt = null;
   ResultSet rs = null;
   int collectForParty = 0;
   int shipmentTypeForParty = 0;
   int collectForCountry = 0;
   int shipmentTypeForCountry = 0;
   String allowed = null;
   try {
     connection = getConnection();
     pStmt = connection.prepareStatement(PartyLovQueries.collectShipmentQuery);
     pStmt.setString(1, partyId);
     rs = pStmt.executeQuery();
     if (rs.next()) {
       collectForParty = rs.getInt("COLLECT_PARTY");
       shipmentTypeForParty = rs.getInt("ST_PARTY");
       collectForCountry = rs.getInt("COLLECT_CON");
       shipmentTypeForCountry = rs.getInt("ST_CON");
     }
     if (collectForCountry != 0 && 1 != collectForCountry)
       allowed =
           shipmentTypeForCountry == 1
               ? "Export"
               : (shipmentTypeForCountry == 2 ? "Import" : "Both");
     else if (collectForParty != 0 && 1 != collectForParty)
       allowed =
           shipmentTypeForParty == 1 ? "Export" : (shipmentTypeForParty == 2 ? "Import" : "Both");
   } finally {
     ConnectionUtil.closeConnection(connection, pStmt, rs);
   }
   return allowed;
 }
  @Override
  public void updatePRICE_nNO(int change_PRICE, int need_orderproductNO) throws Exception {

    Connection conn = null;
    PreparedStatement pstmt = null;

    try {
      conn = getConnection();
      pstmt =
          conn.prepareStatement(
              "UPDATE " + "ORDER_PRODUCT " + "SET OP_PRICE=?  " + "WHERE OP_NO=?");
      pstmt.setInt(1, change_PRICE);
      pstmt.setInt(2, need_orderproductNO);

      pstmt.executeUpdate();

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (pstmt != null)
        try {
          pstmt.close();
        } catch (SQLException se) {
        }
      if (conn != null)
        try {
          conn.close();
        } catch (SQLException se) {
        }
    }
  }
 private String[] getDeptsForBranch(String branch, boolean isInvoicingDept) throws Exception {
   String[] departmentArray = null;
   PreparedStatement getDepartmentPstmt = null;
   ResultSet rs = null;
   Connection connection = null;
   int count = 0;
   try {
     connection = getConnection();
     getDepartmentPstmt =
         connection.prepareStatement(
             PartyLovQueries.getDepartmentQuery,
             ResultSet.TYPE_SCROLL_INSENSITIVE,
             ResultSet.CONCUR_READ_ONLY);
     getDepartmentPstmt.setString(1, branch);
     getDepartmentPstmt.setInt(2, isInvoicingDept ? 1 : 0);
     rs = getDepartmentPstmt.executeQuery();
     while (rs.next()) count++;
     departmentArray = new String[count];
     rs.beforeFirst();
     count = 0;
     while (rs.next()) {
       departmentArray[count] = rs.getString("DEPARTMENT");
       count++;
     }
   } finally {
     ConnectionUtil.closeConnection(connection, getDepartmentPstmt, rs);
   }
   return departmentArray;
 }
Example #13
0
  public void pendientesClaro() throws Exception {
    Connection connPostgres = null;
    String query;

    try {
      // Parámetros de conexión con Postgres
      try {
        Class.forName("org.postgresql.Driver");
      } catch (ClassNotFoundException e) {
        System.out.println("No se encuentra el Driver: " + e.getMessage());
      }
      String username = "postgres";
      String password = "";
      String url = "jdbc:postgresql://localhost:5432/multipagos";
      connPostgres = DriverManager.getConnection(url, username, password);

      corregirClaroDep();

      query = "drop table tmp_claro_dpts;";
      ejecutarQuery(connPostgres, query);

      query =
          "select	b.departamento_id, a.* "
              + "into	tmp_claro_dpts "
              + "from 	tmp_carteraclaro a "
              + "left 	outer join departamento b on upper(rtrim(ltrim(a.departamento))) = upper(rtrim(ltrim(b.departamento_nombre))) "
              + "ORDER BY 1;";
      ejecutarQuery(connPostgres, query);

      query =
          "select a.* into tmp_claro_dpts_2 from cartera_x_departamento a where departamento_id in (select departamento_id from tmp_claro_dpts);";
      ejecutarQuery(connPostgres, query);

      query =
          "delete from tmp_claro_dpts_2 where factura_interna in (select factura_interna from tmp_claro_dpts);";
      ejecutarQuery(connPostgres, query);

      query =
          "update cartera_x_departamento set pagado_claro=true where factura_interna in (select factura_interna from tmp_claro_dpts_2);";
      ejecutarQuery(connPostgres, query);

      query = "drop table tmp_claro_dpts_2;";
      ejecutarQuery(connPostgres, query);

      query = "drop table tmp_claro_dpts;";
      ejecutarQuery(connPostgres, query);

      // return cantidad;

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        if (connPostgres != null) connPostgres.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    // return 0;
  }
Example #14
0
 ////// Renombrar a grabarPortalMaestro()
 public void guardarPortalGestionar(Collection<String[]> array) throws DAOException {
   log.info("guardarPortalGestionar(Collection<String[]> array)");
   Connection cons = null;
   PreparedStatement stmt = null;
   try {
     String query = "update cv_servicio_maestro set columna=? , posicion=? where idservicio=?";
     cons = dataSource.getConnection();
     stmt = cons.prepareStatement(query);
     int posicion = 0;
     for (String[] item : array) {
       stmt.setInt(1, posicion++);
       for (int u = 0; u < item.length; u++) {
         stmt.setInt(2, u);
         stmt.setString(3, item[u]);
         stmt.executeUpdate();
       }
     }
   } catch (SQLException e) {
     log.error(e);
     throw new DAOException(e.toString());
   } catch (Exception e) {
     log.error(e);
     throw new DAOException(e.toString());
   } finally {
     closeStatement(stmt);
     closeConnection(cons);
   }
 }
  public static ResultSet Read() throws ResponseException {
    ResultSet rs = null;
    PreparedStatement statement = null;
    String query = "select * from unlocked;";
    Connection connect = null;
    CachedRowSet crs = null;
    IConnection c = MiscUtil.getIConnection();

    try (CachedRowSet crs2 = RowSetProvider.newFactory().createCachedRowSet()) {
      connect = c.init();
      statement = connect.prepareStatement(query);
      rs = statement.executeQuery();
      crs2.populate(rs);
      crs = crs2.createCopy();
    } catch (SQLException e) {
      logger.error("SQL Error", e);
      throw new ResponseException("SQL Error", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (ResponseException e) {
      throw e;
    } finally {
      try {
        if (statement != null) statement.close();
        if (connect != null) connect.close();
      } catch (SQLException e) {
        logger.error("SQL Error", e);
      }
    }
    return (crs);
  }
Example #16
0
 /**
  * Executes the given SQL statement via plain old JDBC. This will be committed to the database.
  * This SQL statement should be an insert, update or delete statement because it uses the
  * executeUpdate method on Statement.
  *
  * @param sql The SQL to execute.
  * @throws SQLException If the execute failed.
  */
 protected void executeSQL(String sql) throws SQLException {
   Connection c = dataSource.getConnection();
   Statement s = c.createStatement();
   s.executeUpdate(sql);
   s.close();
   c.close();
 }
Example #17
0
 public int guardarProducto(Producto producto) {
   Statement stmt = null;
   Connection conn = null;
   int registrosInsertados = 0;
   try {
     conn = super.getConection();
     stmt = conn.createStatement();
     registrosInsertados =
         stmt.executeUpdate(
             "INSERT INTO productos_aplicables (productos_id, denominacion, precio) "
                 + "VALUES ("
                 + producto.getIdproducto()
                 + " , '"
                 + producto.getDenominacion()
                 + "' , "
                 + producto.getPrecio()
                 + ")");
   } catch (SQLException ex) {
     while (ex != null) {
       ex.printStackTrace();
       ex = ex.getNextException();
     }
     try {
       stmt.close();
       conn.close();
     } catch (SQLException e) {
       while (e != null) {
         e.printStackTrace();
         e = e.getNextException();
       }
     }
   }
   return registrosInsertados;
 }
Example #18
0
 public int update(String sql, Object... params) throws SystemError, LogicError {
   try {
     Connection conn = getConnection();
     try {
       PreparedStatement stm = conn.prepareStatement(sql);
       try {
         setParams(stm, params);
         return stm.executeUpdate();
       } finally {
         stm.close();
       }
     } finally {
       conn.close();
     }
   } catch (LogicError e) {
     logger.error("Error", e);
     throw e;
   } catch (SystemError e) {
     logger.error("Error", e);
     throw e;
   } catch (SQLException e) {
     logger.error("Error", e);
     throw new SystemError("Error in update:" + e, MODULO, DaoUtils.getMethod(e), e);
   } catch (Exception e) {
     logger.error("Error", e);
     throw new SystemError("Error in update:" + e, MODULO, DaoUtils.getMethod(e), e);
   }
 }
Example #19
0
 public <T extends PersistentObject> int updateObject(
     String sql, BeanSqlSetter<T> sqlSetter, T bean) throws SystemError, LogicError {
   try {
     Connection conn = getConnection();
     try {
       PreparedStatement stm = conn.prepareStatement(sql);
       try {
         sqlSetter.setParams(stm, bean);
         int res = stm.executeUpdate();
         if (res == 1) bean.saved();
         return res;
       } finally {
         stm.close();
       }
     } finally {
       conn.close();
     }
   } catch (LogicError e) {
     logger.error("Error", e);
     throw e;
   } catch (SystemError e) {
     logger.error("Error", e);
     throw e;
   } catch (SQLException e) {
     logger.error("Error", e);
     throw new SystemError("Error in update:" + e, MODULO, DaoUtils.getMethod(e), e);
   } catch (Exception e) {
     logger.error("Error", e);
     throw new SystemError("Error in update:" + e, MODULO, DaoUtils.getMethod(e), e);
   }
 }
Example #20
0
  /**
   * 指定ユーザーが所属するグループを<br>
   * 全削除します
   *
   * @param uSid ユーザーSID
   * @return 削除件数
   * @throws SQLException SQL実行例外
   */
  public int deleteUserBelongGroup(int uSid) throws SQLException {

    PreparedStatement pstmt = null;
    int count = 0;
    Connection con = null;
    con = getCon();

    try {
      // SQL文
      SqlBuffer sql = new SqlBuffer();
      sql.addSql(" delete");
      sql.addSql(" from");
      sql.addSql("   CMN_BELONGM");
      sql.addSql(" where ");
      sql.addSql("   USR_SID=?");

      pstmt = con.prepareStatement(sql.toSqlString());
      sql.addIntValue(uSid);

      log__.info(sql.toLogString());
      sql.setParameter(pstmt);
      count = pstmt.executeUpdate();
    } catch (SQLException e) {
      throw e;
    } finally {
      JDBCUtil.closeStatement(pstmt);
    }
    return count;
  }
Example #21
0
  /**
   * グループ所属者全員の管理者区分を変更する
   *
   * @param gsid グループSID
   * @param grpKbn グループ区分
   * @throws SQLException SQL実行例外
   */
  public void updataAllBelongUserGrpKbn(int gsid, int grpKbn) throws SQLException {

    PreparedStatement pstmt = null;
    Connection con = null;
    con = getCon();

    try {
      // SQL文
      SqlBuffer sql = new SqlBuffer();
      sql.addSql(" update ");
      sql.addSql("   CMN_BELONGM");
      sql.addSql(" set");
      sql.addSql("   BEG_GRPKBN = ?");
      sql.addSql(" where");
      sql.addSql("   GRP_SID = ?");

      pstmt = con.prepareStatement(sql.toSqlString());
      sql.addIntValue(grpKbn);
      sql.addIntValue(gsid);
      log__.info(sql.toLogString());
      sql.setParameter(pstmt);
      pstmt.executeUpdate();

    } catch (SQLException e) {
      throw e;
    } finally {
      JDBCUtil.closeStatement(pstmt);
    }
  }
Example #22
0
  /** Web service operation */
  @WebMethod(operationName = "getUserByUID")
  public User getUserByUID(@WebParam(name = "uid") int uid) {
    User result = null;
    try {
      Statement stmt = conn.createStatement();
      String sql;

      sql = "SELECT * FROM user WHERE u_id = ?";
      PreparedStatement dbStatement = conn.prepareStatement(sql);
      dbStatement.setInt(1, uid);

      ResultSet rs = dbStatement.executeQuery();

      // Extract data from result set
      if (rs.next()) {
        result =
            new User(
                rs.getInt("u_id"),
                rs.getString("name"),
                rs.getString("email"),
                rs.getString("password"));
      } else {
        result = new User();
      }
      rs.close();
      stmt.close();
    } catch (SQLException ex) {
      Logger.getLogger(QuestionWS.class.getName()).log(Level.SEVERE, null, ex);
    }
    return result;
  }
  public static void Update(Unlocked p) throws ResponseException {
    PreparedStatement statement = null;
    String query =
        "Update unlocked SET fk_profile_id=?,bonus_info=?,content_info=? where fk_profile_id=?;";
    Connection connect = null;
    IConnection c = MiscUtil.getIConnection();

    try {
      connect = c.init();
      statement = connect.prepareStatement(query);
      statement.setLong(1, p.getProfileId());
      statement.setString(2, p.getBonusInfo());
      statement.setString(3, p.getContentInfo());
      statement.setLong(4, p.getProfileId());
      statement.executeUpdate();
    } catch (SQLException e) {
      logger.error("SQL Error", e);
      throw new ResponseException("SQL Error", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (ResponseException e) {
      throw e;
    } finally {
      try {
        if (statement != null) statement.close();
        if (connect != null) connect.close();
      } catch (SQLException e) {
        logger.error("SQL Error", e);
      }
    }
  }
  /** Finishes the execution context */
  public static void finish() {
    Connection conn = JForumExecutionContext.getConnection(false);

    if (conn != null) {
      if (SystemGlobals.getBoolValue(ConfigKeys.DATABASE_USE_TRANSACTIONS)) {
        if (JForumExecutionContext.shouldRollback()) {
          try {
            conn.rollback();
          } catch (Exception e) {
            logger.error("Error while rolling back a transaction", e);
          }
        } else {
          try {
            conn.commit();
          } catch (Exception e) {
            logger.error("Error while commiting a transaction", e);
          }
        }
      }

      try {
        DBConnection.getImplementation().releaseConnection(conn);
      } catch (Exception e) {
        logger.error("Error while releasing the connection : " + e, e);
      }
    }

    userData.set(null);
  }
Example #25
0
  public static UserLoginResponse userLogIn(final UserLoginRequest userInfo)
      throws SQLException, IOException, PropertyVetoException, ClassNotFoundException {
    final String query = Query.SELECT_USER_DETAILS.toString();
    final Connection conn = DataSource.getInstance().getConnection();
    final PreparedStatement stmt = conn.prepareStatement(query);
    stmt.setString(1, userInfo.getUserId());

    ResultSet rs = stmt.executeQuery();
    if (!rs.next()) {
      conn.close();
      throw new SQLException("User ID " + userInfo.getUserId() + " does not exist.");
    } else {
      if (!rs.getString("password").equals(userInfo.getPassword())) {
        conn.close();
        throw new SQLException("Authentication problem.");
      }
      UserLoginResponse resp =
          new UserLoginResponse(
              "200",
              "Login Success.",
              userInfo.getUserId(),
              rs.getString("name"),
              rs.getString("password"),
              rs.getString("clickDelayInSeconds"),
              rs.getString("uploadIntervalInSeconds"));
      conn.close();
      return resp;
    }
  }
Example #26
0
  public boolean changePassword(String oldPassword, String newPassword) {
    if (!passwordExist()) {
      _log.warning(
          "[SecondaryPasswordAuth]" + _activeClient.getAccountName() + " forced changePassword");
      _activeClient.closeNow();
      return false;
    }

    if (!checkPassword(oldPassword, true)) {
      return false;
    }

    if (!validatePassword(newPassword)) {
      _activeClient.sendPacket(new Ex2ndPasswordAck(2, Ex2ndPasswordAck.WRONG_PATTERN));
      return false;
    }

    newPassword = cryptPassword(newPassword);

    try (Connection con = DatabaseFactory.getInstance().getConnection();
        PreparedStatement statement = con.prepareStatement(UPDATE_PASSWORD)) {
      statement.setString(1, newPassword);
      statement.setString(2, _activeClient.getAccountName());
      statement.setString(3, VAR_PWD);
      statement.execute();
    } catch (Exception e) {
      _log.log(Level.SEVERE, "Error while reading password.", e);
      return false;
    }

    _password = newPassword;
    _authed = false;
    return true;
  }
Example #27
0
 public void setBlockCheck(World w, int x, int y, int z, int m, byte d, int id) {
   // List of blocks that a door cannot be placed on
   List<Integer> ids =
       Arrays.asList(
           0, 6, 8, 9, 10, 11, 18, 20, 26, 27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 44, 46,
           50, 51, 53, 54, 55, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 75, 76,
           77, 78, 79, 81, 83, 85, 89, 92, 93, 94, 96, 101, 102, 104, 105, 106, 107, 108, 109, 111,
           113, 114, 115, 116, 117, 118, 119, 120, 122, 128, 130, 131, 132, 134, 135, 136);
   Block b = w.getBlockAt(x, y, z);
   Integer bId = Integer.valueOf(b.getTypeId());
   byte bData = b.getData();
   Statement statement = null;
   if (ids.contains(bId)) {
     b.setTypeIdAndData(m, d, true);
     // remember replaced block location, TypeId and Data so we can restore it later
     try {
       Connection connection = service.getConnection();
       statement = connection.createStatement();
       String replaced = w.getName() + ":" + x + ":" + y + ":" + z + ":" + bId + ":" + bData;
       String queryReplaced =
           "UPDATE tardis SET replaced = '" + replaced + "' WHERE tardis_id = " + id;
       statement.executeUpdate(queryReplaced);
       statement.close();
     } catch (SQLException e) {
       plugin.console.sendMessage(plugin.pluginName + "Set Replaced Block Error: " + e);
     } finally {
       try {
         statement.close();
       } catch (Exception e) {
       }
     }
   }
 }
Example #28
0
 // 创建新表
 public boolean createTable(String tableName) {
   try {
     Connection conn = getConn();
     if (conn != null) {
       StringBuilder sql = new StringBuilder("CREATE TABLE ");
       sql.append(tableName);
       sql.append(" (");
       sql.append("serialno int(11) NOT NULL AUTO_INCREMENT,");
       sql.append("title varchar(128) NOT NULL,");
       sql.append("smalldesc varchar(512) NOT NULL,");
       sql.append("smallurl varchar(256) DEFAULT NULL,");
       sql.append("source varchar(32) NOT NULL,");
       sql.append("releasetime bigint(20) NOT NULL,");
       sql.append("content varchar(128) NOT NULL,");
       sql.append("classify varchar(16) NOT NULL,");
       sql.append("curl varchar(256) NOT NULL,");
       sql.append("createtime varchar(14) NOT NULL,");
       sql.append("PRIMARY KEY (serialno)");
       sql.append(") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=gbk");
       PreparedStatement stat = conn.prepareStatement(sql.toString());
       stat.executeUpdate();
       conn.close();
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return true;
 }
  @Override
  public void deleteOrderProduct(OrderProductDTO orderproduct) throws Exception {

    Connection conn = null;
    PreparedStatement pstmt = null;

    try {
      conn = getConnection();
      pstmt = conn.prepareStatement("DELETE FROM ORDER_PRODUCT WHERE OP_NO=?");
      pstmt.setInt(1, orderproduct.getOP_no());

      pstmt.executeUpdate();

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (pstmt != null)
        try {
          pstmt.close();
        } catch (SQLException se) {
        }
      if (conn != null)
        try {
          conn.close();
        } catch (SQLException se) {
        }
    }
  }
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    int id = Integer.valueOf(request.getParameter("id"));

    Connection conexao = null;
    try {
      conexao = AbstractConnectionFactory.getConexao();
      OrcamentoDao orcamentoDao = new OrcamentoDao(conexao);
      orcamentoDao.excluirOrcamento(id);

      write(response, "Orcamento excluido com sucesso");

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      write(response, "ERRO codigo CNFE10 " + e.getMessage());
    } catch (SQLException e) {
      e.printStackTrace();
      write(response, "ERRO codigo SQLE10 " + e.getMessage());
    } finally {
      try {
        conexao.close();
      } catch (SQLException e) {
        e.printStackTrace();
        write(response, "ERRO codigo SQLE10 " + e.getMessage());
      }
    }
  }