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 #2
1
 public Collection ejbGetRuoliSicurezza_View() {
   BMPConnection bmp = getConnection();
   try {
     PreparedStatement ps =
         bmp.prepareStatement(
             "SELECT "
                 + "COD_RUO_SIC, NOM_RUO_SIC, DES_RUO_SIC "
                 + "FROM "
                 + "ANA_RUO_SIC_TAB "
                 + "ORDER BY "
                 + "NOM_RUO_SIC");
     ResultSet rs = ps.executeQuery();
     java.util.ArrayList al = new java.util.ArrayList();
     while (rs.next()) {
       RuoliSicurezza_View obj = new RuoliSicurezza_View();
       obj.COD_RUO_SIC = rs.getLong(1);
       obj.NOM_RUO_SIC = rs.getString(2);
       obj.DES_RUO_SIC = rs.getString(3);
       al.add(obj);
     }
     bmp.close();
     return al;
   } catch (Exception ex) {
     throw new EJBException(ex);
   } finally {
     bmp.close();
   }
 }
Example #3
1
 /**
  * checks if a particular chained task is ready for processing
  *
  * @param chain_id the id this process is part off order
  * @param process_id the process_id
  * @return
  * @throws java.sql.SQLException
  */
 public boolean canExecute(int chain_id, int process_id) throws SQLException {
   boolean isReady = false;
   try (AutoCloseableDBConnection c = new AutoCloseableDBConnection();
       PreparedStatement getChain =
           c.prepareStatement(
               "SELECT process_id,busy FROM chain_activities WHERE (chain_id=?) ORDER BY process_id")) {
     getChain.setInt(1, chain_id);
     LinkedHashMap<Integer, Boolean> clearedToRunMap = new LinkedHashMap<>();
     try (ResultSet executeQuery = getChain.executeQuery()) {
       while (executeQuery.next()) {
         clearedToRunMap.put(executeQuery.getInt("process_id"), executeQuery.getBoolean("busy"));
       }
     }
     int predecessingProcess = -1;
     for (Entry<Integer, Boolean> aProcess : clearedToRunMap.entrySet()) {
       if (aProcess.getKey() == process_id) {
         break;
       } else {
         predecessingProcess = aProcess.getKey();
         // check if this process is already busy
       }
     }
     if (predecessingProcess == -1) {
       // then there's no predecessing process, meaning it can be run for sure
       isReady = true;
     } else if (clearedToRunMap.get(predecessingProcess)) {
       try ( // then it's busy, but it can be that it's not yet done !
       ProcessDAO pdao = ProcessDAO.getInstance()) {
         isReady = pdao.isCompletedProcess(process_id);
       }
     }
   }
   return isReady;
 }
  @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) {
        }
    }
  }
  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);
    }
  }
Example #6
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;
  }
  /** 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 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;
 }
Example #9
1
  private FileContent getFileContentWithChunkChecksums(FileChecksum fileChecksum) {
    try (PreparedStatement preparedStatement =
        getStatement("filecontent.select.all.getFileContentByChecksumWithChunkChecksums.sql")) {
      preparedStatement.setString(1, fileChecksum.toString());

      try (ResultSet resultSet = preparedStatement.executeQuery()) {
        FileContent fileContent = null;

        while (resultSet.next()) {
          if (fileContent == null) {
            fileContent = new FileContent();

            fileContent.setChecksum(
                FileChecksum.parseFileChecksum(resultSet.getString("checksum")));
            fileContent.setSize(resultSet.getLong("size"));
          }

          // Add chunk references
          ChunkChecksum chunkChecksum =
              ChunkChecksum.parseChunkChecksum(resultSet.getString("chunk_checksum"));
          fileContent.addChunk(chunkChecksum);
        }

        return fileContent;
      }
    } catch (SQLException e) {
      throw new RuntimeException(e);
    }
  }
Example #10
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 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;
 }
Example #12
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;
 }
Example #13
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;
  }
  /*
   wyświetlenie zawartości lodówki w formie listy
  */
  public List<Fridge> getAllProducts(int userid) {
    List<Fridge> products = new ArrayList<Fridge>();

    try {
      PreparedStatement preparedStatement =
          connection.prepareStatement("select * from fridge where userid=?");
      preparedStatement.setInt(1, userid);
      ResultSet rs = preparedStatement.executeQuery();
      // ResultSet rs = preparedStatement.executeQuery();
      // Statement statement = connection.createStatement();
      // ResultSet rs = statement.executeQuery("select * from fridge where userid=?");
      while (rs.next()) {
        // wypełnianie listy
        Fridge product = new Fridge();
        product.setProductID(rs.getInt("ProductID"));
        product.setName(rs.getString("ProductName"));
        product.setAmount(rs.getInt("ProductAmount"));
        product.setUserID(rs.getInt("UserID"));
        products.add(product);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }

    return products;
  }
Example #15
0
 /**
  * Get Accessible Goals
  *
  * @param ctx context
  * @return array of goals
  */
 public static MGoal[] getGoals(Ctx ctx) {
   ArrayList<MGoal> list = new ArrayList<MGoal>();
   String sql = "SELECT * FROM PA_Goal WHERE IsActive='Y' " + "ORDER BY SeqNo";
   sql =
       MRole.getDefault(ctx, false)
           .addAccessSQL(sql, "PA_Goal", false, true); // 	RW to restrict Access
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   try {
     pstmt = DB.prepareStatement(sql, (Trx) null);
     rs = pstmt.executeQuery();
     while (rs.next()) {
       MGoal goal = new MGoal(ctx, rs, null);
       goal.updateGoal(false);
       list.add(goal);
     }
   } catch (Exception e) {
     s_log.log(Level.SEVERE, sql, e);
   } finally {
     DB.closeStatement(pstmt);
     DB.closeResultSet(rs);
   }
   MGoal[] retValue = new MGoal[list.size()];
   list.toArray(retValue);
   return retValue;
 } //	getGoals
Example #16
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;
  }
Example #17
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 #18
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 #19
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 #20
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 #21
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);
  }
 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 #24
0
  @Override
  public void loadData(Object... params) {
    if (sql == null)
      throw new IllegalStateException(
          "Table not initialized. Please use prepareTable method first");

    int selectedId = getSelectedId();

    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, null);
      DB.setParameters(pstmt, params);
      rs = pstmt.executeQuery();
      this.loadTable(rs);
    } catch (Exception e) {
      log.log(Level.SEVERE, sql, e);
    } finally {
      DB.close(rs, pstmt);
      rs = null;
      pstmt = null;
    }

    selectById(selectedId);
  }
Example #25
0
 public void ejbLoad() {
   BMPConnection bmp = getConnection();
   try {
     PreparedStatement ps =
         bmp.prepareStatement(
             "SELECT "
                 + "COD_RUO_SIC, NOM_RUO_SIC, DES_RUO_SIC "
                 + "FROM "
                 + "ANA_RUO_SIC_TAB "
                 + "WHERE "
                 + "COD_RUO_SIC=?");
     ps.setLong(1, COD_RUO_SIC);
     ResultSet rs = ps.executeQuery();
     if (rs.next()) {
       this.COD_RUO_SIC = rs.getLong("COD_RUO_SIC");
       this.NOM_RUO_SIC = rs.getString("NOM_RUO_SIC");
       this.DES_RUO_SIC = rs.getString("DES_RUO_SIC");
     } else {
       throw new NoSuchEntityException("Ruolo per la sicurezza con ID= non trovato");
     }
   } catch (Exception ex) {
     throw new EJBException(ex);
   } finally {
     bmp.close();
   }
 }
Example #26
0
 /**
  * Get Restriction Lines
  *
  * @param reload reload data
  * @return array of lines
  */
 public MGoalRestriction[] getRestrictions(boolean reload) {
   if (m_restrictions != null && !reload) return m_restrictions;
   ArrayList<MGoalRestriction> list = new ArrayList<MGoalRestriction>();
   //
   String sql =
       "SELECT * FROM PA_GoalRestriction "
           + "WHERE PA_Goal_ID=? AND IsActive='Y' "
           + "ORDER BY Org_ID, C_BPartner_ID, M_Product_ID";
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   try {
     pstmt = DB.prepareStatement(sql, get_Trx());
     pstmt.setInt(1, getPA_Goal_ID());
     rs = pstmt.executeQuery();
     while (rs.next()) list.add(new MGoalRestriction(getCtx(), rs, get_Trx()));
   } catch (Exception e) {
     log.log(Level.SEVERE, sql, e);
   } finally {
     DB.closeStatement(pstmt);
     DB.closeResultSet(rs);
   }
   //
   m_restrictions = new MGoalRestriction[list.size()];
   list.toArray(m_restrictions);
   return m_restrictions;
 } //	getRestrictions
Example #27
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 #28
0
 public void ejbStore() {
   if (!isModified()) {
     return;
   }
   BMPConnection bmp = getConnection();
   try {
     PreparedStatement ps =
         bmp.prepareStatement(
             "UPDATE "
                 + "ANA_RUO_SIC_TAB "
                 + "SET "
                 + "COD_RUO_SIC=?, "
                 + "NOM_RUO_SIC=?, "
                 + "DES_RUO_SIC=? "
                 + "WHERE "
                 + "COD_RUO_SIC=?");
     ps.setLong(1, COD_RUO_SIC);
     ps.setString(2, NOM_RUO_SIC);
     ps.setString(3, DES_RUO_SIC);
     ps.setLong(4, COD_RUO_SIC);
     if (ps.executeUpdate() == 0) {
       throw new NoSuchEntityException("Ruolo per la sicurezza con ID= non trovato");
     }
   } catch (Exception ex) {
     throw new EJBException(ex);
   } finally {
     bmp.close();
   }
 }
  @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) {
        }
    }
  }
Example #30
0
 public void remover(int id) throws SQLException {
   String sql = "delete from cliente where cli_codigo=?";
   PreparedStatement stmt = this.conexao.prepareStatement(sql);
   stmt.setInt(1, id);
   stmt.execute();
   stmt.close();
 }