Example #1
0
  private void LoginButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_LoginButtonActionPerformed
    // TODO add your handling code here:
    String sql = "select * from bruker where brukerNavn=? and brukerPassord=?";

    try {
      int userType = accountType.getSelectedIndex();

      pst = conn.prepareStatement(sql);
      pst.setString(1, UsrInput.getText());
      pst.setString(2, PswdInput.getText());
      rs = pst.executeQuery();

      if (rs.next()) {
        // JOptionPane.showMessageDialog(null,"Username and password is correct");
        close();
        if (userType == 0) {
          MainPage m = new MainPage();
          m.setVisible(true);
        } else {
          fMainPage fm = new fMainPage();
          fm.setVisible(true);
        }

      } else {
        JOptionPane.showMessageDialog(null, "Username or password is incorrect");
      }
    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, e);
    }
  } // GEN-LAST:event_LoginButtonActionPerformed
 public ArrayList<File> getFiles(String sql) {
   ArrayList<File> list = new ArrayList<File>();
   Connection conn = null;
   ResultSet rs = null;
   PreparedStatement ps = null;
   try {
     conn = getConnection();
     ps =
         conn.prepareStatement(
             sql.toLowerCase().startsWith("select")
                 ? sql
                 : ("SELECT FILENAME, MODIFIED FROM FILES WHERE " + sql));
     rs = ps.executeQuery();
     while (rs.next()) {
       String filename = rs.getString("FILENAME");
       long modified = rs.getTimestamp("MODIFIED").getTime();
       File file = new File(filename);
       if (file.exists() && file.lastModified() == modified) {
         list.add(file);
       }
     }
   } catch (SQLException se) {
     LOGGER.error(null, se);
     return null;
   } finally {
     close(rs);
     close(ps);
     close(conn);
   }
   return list;
 }
Example #3
0
  public static int retornaQtdTotal(Connection conn, JobProtheus job) throws SQLException {

    PreparedStatement stmt = null;
    ResultSet rs = null;
    int qtdTotal = 0;
    int qtdSucata = 0;

    String sqlVerQtd =
        "select job, sum(qtd_transf), sum(hr_tot), sum(qtd_sucata) from jobLote where job = ? and operacao = ? group by job";
    stmt = conn.prepareStatement(sqlVerQtd);
    stmt.setString(1, job.getJob().trim());
    stmt.setInt(2, job.getOperacao());
    rs = stmt.executeQuery();

    String qtdJob = "";
    double totHora = 0;

    while (rs.next()) {
      qtdJob = rs.getString(1); // numero job
      qtdTotal = rs.getInt(2); // quantidade total
      totHora = rs.getInt(3); // hora total em minutos
      qtdSucata = rs.getInt(4);
    }

    return qtdTotal + qtdSucata;
  }
  public void actionPerformed(ActionEvent ae) {
    if (ae.getSource() == b1) {
      try {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection con =
            DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "123");
        PreparedStatement ps =
            con.prepareStatement("select * from LoginForm where username=? and password=?");
        String UserName = t1.getText();
        String Password = jp1.getText();
        ps.setString(1, UserName);
        ps.setString(2, Password);
        ResultSet rs = ps.executeQuery();
        boolean flag = rs.next();
        if (flag) {
          new Main();
          f.setVisible(false);
        } else {
          JOptionPane.showMessageDialog(null, "Please Enter valid Name And Password");
        }

      } catch (Exception e) {
        System.out.println("Error:" + e);
      }
    } else if (ae.getSource() == b2) {
      t1.setText("");
      jp1.setText("");
    } else if (ae.getSource() == b3) {

      f.setVisible(false);
    }
  }
Example #5
0
  public JobIniciado retornaUltimoLote(Connection conn, String job, int operacao)
      throws SQLException {

    String sql =
        " select job, operacao, tripulacao,recurso, max(data_fim) \n"
            + "from joblote where job = ? and operacao = ? \n"
            + "group by job, operacao, tripulacao, recurso ";

    PreparedStatement stmt = null;
    ResultSet rs = null;
    JobIniciado iniciado = null;

    stmt = conn.prepareStatement(sql);
    stmt.setString(1, job.trim().replace(".", ""));
    stmt.setInt(2, operacao);
    rs = stmt.executeQuery();

    if (rs.next()) {

      iniciado = new JobIniciado();
      iniciado.setJob(rs.getString(1));
      iniciado.setOperacao(rs.getInt(2));
      iniciado.setTripulacao(rs.getDouble(3));
      iniciado.setRecurso(rs.getString(4));
      Timestamp data = rs.getTimestamp(5);
      iniciado.setData(Validacoes.getDataHoraString(data));
    }

    return iniciado;
  }
Example #6
0
  public ValoresAtualizaJob retornaNovosValores(Connection conn, JobLote job) throws SQLException {

    PreparedStatement stmt = null;
    ResultSet rs = null;
    ValoresAtualizaJob obj = null;

    String sql =
        " select sum(qtd_transf) qtd_transf, sum(qtd_sucata) qtd_sucata, sum(hr_tot) hr_tot from joblote\n"
            + " where job = ? and operacao = ? ";

    stmt = conn.prepareStatement(sql);
    stmt.setString(1, job.getJob().trim().replace(".", ""));
    stmt.setInt(2, job.getOperNum());
    rs = stmt.executeQuery();

    if (rs.next()) {

      obj = new ValoresAtualizaJob();
      obj.setQtdTransf(rs.getDouble("qtd_transf"));
      obj.setQtdSucata(rs.getDouble("qtd_sucata"));
      obj.setHoraTotal(rs.getDouble("hr_tot"));
    }

    return obj;
  }
Example #7
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
 public ArrayList<String> getStrings(String sql) {
   ArrayList<String> list = new ArrayList<String>();
   Connection conn = null;
   ResultSet rs = null;
   PreparedStatement ps = null;
   try {
     conn = getConnection();
     ps = conn.prepareStatement(sql);
     rs = ps.executeQuery();
     while (rs.next()) {
       String str = rs.getString(1);
       if (isBlank(str)) {
         if (!list.contains(NONAME)) {
           list.add(NONAME);
         }
       } else if (!list.contains(str)) {
         list.add(str);
       }
     }
   } catch (SQLException se) {
     LOGGER.error(null, se);
     return null;
   } finally {
     close(rs);
     close(ps);
     close(conn);
   }
   return list;
 }
Example #9
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 #10
0
  public void excluirLote(List<JobLote> listaExcluir) {

    Connection conn = null;
    PreparedStatement stmt = null;
    String sql = "delete from joblote where job = ? and operacao = ? and lote =? ";

    try {

      conn = GerenciaConexaoSQLServer.abreConexao();
      conn.setAutoCommit(false);

      for (int i = 0; i <= listaExcluir.size() - 1; i++) {

        JobLote job = listaExcluir.get(i);

        stmt = conn.prepareStatement(sql);
        stmt.setString(1, job.getJob().trim().replace(".", ""));
        stmt.setInt(2, job.getOperNum());
        stmt.setInt(3, job.getLote());
        stmt.executeUpdate();

        alteraJobAposExclusao(conn, job);

        gravaJobsExcluidos(
            conn, job.getJob().trim().replace(".", ""), job.getOperNum(), job.getLote());
      }

      // adiciona a op na tela inicial
      for (int i = 0; i <= listaExcluir.size() - 1; i++) {
        JobLote job = listaExcluir.get(i);
        JobProtheus jobProtheus = retornaJob(conn, job);
        adicionaOPTelaInicial(conn, jobProtheus, job);
      }

      JOptionPane.showMessageDialog(this, "Job Excluido com Sucesso!");
      conn.commit();

    } catch (SQLException e) {

      if (conn != null) {

        try {

          conn.rollback();
          conn.setAutoCommit(true);

          JOptionPane.showMessageDialog(null, "Não foi possivel excluir! Descrição: " + e);

        } catch (SQLException ex) {
          JOptionPane.showMessageDialog(null, "Erro ao fazer o rollback! Descrição: " + ex);
        }
      }

    } finally {
      GerenciaConexaoSQLServer.closeConexao(conn, stmt);
    }
  }
  private void fullAssociated() {

    boolean associated = true;

    String SQL =
        "Select * "
            + "from XX_VMR_REFERENCEMATRIX "
            + "where M_product IS NULL AND XX_VMR_PO_LINEREFPROV_ID="
            + LineRefProv.get_ID();

    try {
      PreparedStatement pstmt = DB.prepareStatement(SQL, null);
      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        associated = false;
      }

      rs.close();
      pstmt.close();

    } catch (Exception a) {
      log.log(Level.SEVERE, SQL, a);
    }

    if (associated == true) {
      String SQL10 =
          "UPDATE XX_VMR_PO_LineRefProv "
              + " SET XX_ReferenceIsAssociated='Y'"
              + " WHERE XX_VMR_PO_LineRefProv_ID="
              + LineRefProv.getXX_VMR_PO_LineRefProv_ID();

      DB.executeUpdate(null, SQL10);

      //			LineRefProv.setXX_ReferenceIsAssociated(true);
      //			LineRefProv.save();

      int dialog = Env.getCtx().getContextAsInt("#Dialog_Associate_Aux");

      if (dialog == 1) {
        ADialog.info(m_WindowNo, m_frame, "MustRefresh");
        Env.getCtx().remove("#Dialog_Associate_Aux");
      }

    } else {
      String SQL10 =
          "UPDATE XX_VMR_PO_LineRefProv "
              + " SET XX_ReferenceIsAssociated='N'"
              + " WHERE XX_VMR_PO_LineRefProv_ID="
              + LineRefProv.getXX_VMR_PO_LineRefProv_ID();

      DB.executeUpdate(null, SQL10);
      //			LineRefProv.setXX_ReferenceIsAssociated(false);
      //			LineRefProv.save();
    }
  }
Example #12
0
  public void desativaIniciado(Connection conn, String op, int operacao) throws SQLException {

    String sql = "update jobsiniciados set ativo = 0 where job = ? and operacao = ? ";
    PreparedStatement stmt = null;

    stmt = conn.prepareStatement(sql);
    stmt.setString(1, op.trim().replace(".", ""));
    stmt.setInt(2, operacao);
    stmt.executeUpdate();
  }
  public static ResultSet collectRows1(String s) throws Exception {

    try {

      pps1.setString(1, s);
      rs = pps1.executeQuery();
    } catch (Exception e13) {
      System.out.println("" + e13);
    }
    return rs;
  }
Example #14
0
 private void Update_table() {
   try {
     Connection conn = getConnect();
     String sql = "SELECT * FROM LoggedInPeople";
     PreparedStatement pst = conn.prepareStatement(sql);
     ResultSet rs = pst.executeQuery();
     PeopleLoggedIn.setModel(DbUtils.resultSetToTableModel(rs));
     closeConnect();
   } catch (Exception e) {
     System.out.println(e);
   }
 }
Example #15
0
  public void gravaJobsExcluidos(Connection conn, String job, int operacao, int lote)
      throws SQLException {

    PreparedStatement stmt = null;
    String insert = "insert into joblotesexcluidos (job, operacao, lote) values (?,?,?)";

    stmt = conn.prepareStatement(insert);
    stmt.setString(1, job.trim());
    stmt.setInt(2, operacao);
    stmt.setInt(3, lote);
    stmt.executeUpdate();
  }
  public void cleanup() {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
      conn = getConnection();
      ps = conn.prepareStatement("SELECT COUNT(*) FROM FILES");
      rs = ps.executeQuery();
      dbCount = 0;

      if (rs.next()) {
        dbCount = rs.getInt(1);
      }

      rs.close();
      ps.close();
      PMS.get().getFrame().setStatusLine(Messages.getString("DLNAMediaDatabase.2") + " 0%");
      int i = 0;
      int oldpercent = 0;

      if (dbCount > 0) {
        ps =
            conn.prepareStatement(
                "SELECT FILENAME, MODIFIED, ID FROM FILES",
                ResultSet.TYPE_FORWARD_ONLY,
                ResultSet.CONCUR_UPDATABLE);
        rs = ps.executeQuery();
        while (rs.next()) {
          String filename = rs.getString("FILENAME");
          long modified = rs.getTimestamp("MODIFIED").getTime();
          File file = new File(filename);
          if (!file.exists() || file.lastModified() != modified) {
            rs.deleteRow();
          }
          i++;
          int newpercent = i * 100 / dbCount;
          if (newpercent > oldpercent) {
            PMS.get()
                .getFrame()
                .setStatusLine(Messages.getString("DLNAMediaDatabase.2") + newpercent + "%");
            oldpercent = newpercent;
          }
        }
      }
    } catch (SQLException se) {
      LOGGER.error(null, se);
    } finally {
      close(rs);
      close(ps);
      close(conn);
    }
  }
Example #17
0
  public JobProtheus retornaJob(Connection conn, JobLote lote) throws SQLException {

    ResultSet rs = null;
    PreparedStatement stmt = null;
    JobProtheus job = null;

    String sql = "select job , B1_DESC,  operacao , produto,  ";
    sql += " dt_release, job_start_date , qtd_release, setor, qtd_transf ";
    sql += " from job left join  " + DB_PROTHEUS.trim() + ".dbo.SB1000 SB1 ";
    sql += " on(produto collate SQL_Latin1_General_CP1_CI_AS = B1_COD) ";
    sql += " where job = ? and operacao = ? and SB1.D_E_L_E_T_ = '' ";
    sql += " order by dt_release, produto ";

    stmt = conn.prepareStatement(sql);
    stmt.setString(1, lote.getJob().trim());
    stmt.setInt(2, lote.getOperNum());
    rs = stmt.executeQuery();

    while (rs.next()) {

      String nJob = rs.getString("job");
      int operacao = rs.getInt("operacao");
      String produto = rs.getString("produto");
      Date dataEmissao = rs.getDate("dt_release");
      Date dataPrevisaoInicio = rs.getDate("job_start_date");
      String descricaoProduto = rs.getString("B1_DESC");
      double quantidade = rs.getDouble("qtd_release");
      String wc = rs.getString("setor");

      String emissao = dataEmissao != null ? getDateToString(dataEmissao) : "";
      String previsaoInicio = dataPrevisaoInicio != null ? getDateToString(dataPrevisaoInicio) : "";

      job = new JobProtheus();

      job.setStatus("");
      job.setJob(nJob);
      job.setOperacao(operacao);
      job.setProduto(produto.trim());
      job.setDataEmissao(emissao);
      job.setQuantidadeLiberada(quantidade);
      job.setDescricaoProduto(descricaoProduto);
      job.setCentroTrabalho(wc);

      double qtdTotal = retornaQtdTotal(conn, job); // calcula o total transferido para o job
      job.setQuantidadeCompleta(qtdTotal);
      job.setDataPrivisaoInicio(previsaoInicio);
      job.setQuantidadeFaltando(quantidade - qtdTotal); // seta o valor qtd faltando
    }

    return job; // retorna lista de jobs
  }
Example #18
0
  public boolean verificaSeSetorTemLinhaTempo(Connection conn, String setor) throws SQLException {

    PreparedStatement stmt = null;
    ResultSet rs = null;
    String sql = "select linha_tempo from setor where setor = ? and linha_tempo = ? ";

    stmt = conn.prepareStatement(sql);
    stmt.setString(1, setor.trim());
    stmt.setBoolean(2, true);
    rs = stmt.executeQuery();

    if (rs.next()) {
      return true;
    } else {
      return false;
    }
  }
Example #19
0
  public boolean verificarSeJobEstaTabelaIniciado(Connection conn, String job, int operacao)
      throws SQLException {

    PreparedStatement stmt = null;
    ResultSet rs = null;
    String update = "select ativo from jobsiniciados where job = ? and operacao = ?";

    stmt = conn.prepareStatement(update);
    stmt.setString(1, job.trim().replace(".", ""));
    stmt.setInt(2, operacao);
    rs = stmt.executeQuery();

    if (rs.next()) {
      return true;
    }

    return false;
  }
Example #20
0
  // event handling
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnok) {
      PreparedStatement pstm;
      ResultSet rs;
      String sql;
      // if no entries has been made and hit ok button throw an error
      // you can do this step using try clause as well
      if ((tf1.getText().equals("") && (tf2.getText().equals("")))) {
        lblmsg.setText("Enter your details ");
        lblmsg.setForeground(Color.magenta);
      } else {

        try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          Connection connect = DriverManager.getConnection("jdbc:odbc:student_base");
          System.out.println("Connected to the database");
          pstm = connect.prepareStatement("insert into student_base values(?,?)");
          pstm.setString(1, tf1.getText());
          pstm.setString(2, tf2.getText());
          // execute method to execute the query
          pstm.executeUpdate();
          lblmsg.setText("Details have been added to database");

          // closing the prepared statement  and connection object
          pstm.close();
          connect.close();
        } catch (SQLException sqe) {
          System.out.println("SQl error");
        } catch (ClassNotFoundException cnf) {
          System.out.println("Class not found error");
        }
      }
    }
    // upon clickin button addnew , your textfield will be empty to enternext record
    if (e.getSource() == btnaddnew) {
      tf1.setText("");
      tf2.setText("");
    }

    if (e.getSource() == btnexit) {
      System.exit(1);
    }
  }
Example #21
0
 public void check_User() {
   String user = "";
   String sql = "Select * from user";
   boolean user_valid = false;
   try {
     PreparedStatement stat = konek.prepareStatement(sql);
     ResultSet rset = stat.executeQuery();
     while (rset.next()) {
       user = rset.getString("username");
       if (user.equalsIgnoreCase(dataUser)) {
         user_valid = true;
         status_Proses(true, "Sukses!!!User Name Valid...", 20);
       }
     }
     if (user_valid == false) {
       status_Proses(false, "Gagal!!!User yang Anda Masukan Salah...", 20);
     }
   } catch (SQLException se) {
   }
 }
Example #22
0
 public void check_Password() {
   String password = "******";
   String sql = "Select * from user where user_id = '" + dataUser + "'";
   boolean password_valid = false;
   try {
     PreparedStatement stat = konek.prepareStatement(sql);
     ResultSet rset = stat.executeQuery();
     while (rset.next()) {
       password = rset.getString("psw");
       if (password.equalsIgnoreCase(dataPassword)) {
         password_valid = true;
         status_Proses(true, "Sukses!!!Password Valid...", 20);
       }
     }
     if (password_valid == false) {
       status_Proses(false, "Gagal!!!Password yang Anda Masukan Salah...", 20);
     }
   } catch (SQLException se) {
   }
 }
Example #23
0
 /**
  * Get Goals with Measure
  *
  * @param ctx context
  * @param PA_Measure_ID measure
  * @return goals
  */
 public static MGoal[] getMeasureGoals(Ctx ctx, int PA_Measure_ID) {
   ArrayList<MGoal> list = new ArrayList<MGoal>();
   String sql = "SELECT * FROM PA_Goal WHERE IsActive='Y' AND PA_Measure_ID=? " + "ORDER BY SeqNo";
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   try {
     pstmt = DB.prepareStatement(sql, (Trx) null);
     pstmt.setInt(1, PA_Measure_ID);
     rs = pstmt.executeQuery();
     while (rs.next()) list.add(new MGoal(ctx, rs, null));
   } 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;
 } //	getMeasureGoals
Example #24
0
  /**
   * Get User Goals
   *
   * @param ctx context
   * @param AD_User_ID user
   * @return array of goals
   */
  public static MGoal[] getUserGoals(Ctx ctx) {
    int AD_Role_ID = ctx.getAD_Role_ID();
    MRole role = MRole.get(ctx, AD_Role_ID);
    int AD_User_ID = ctx.getAD_User_ID();

    if (AD_User_ID < 0) return getTestGoals(ctx);
    ArrayList<MGoal> list = new ArrayList<MGoal>();
    String sql =
        "SELECT * FROM PA_Goal g "
            + "WHERE IsActive='Y'"
            + " AND AD_Client_ID=?" //	#1
            + " AND (";
    if (!role.isWebStoreRole()) sql += " (AD_User_ID IS NULL AND AD_Role_ID IS NULL) OR ";
    sql +=
        " AD_User_ID=?" //	#2
            + " OR EXISTS (SELECT * FROM AD_User_Roles ur "
            + "WHERE ?=ur.AD_User_ID AND g.AD_Role_ID=ur.AD_Role_ID AND ur.IsActive='Y')) "
            + "ORDER BY SeqNo";
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, (Trx) null);
      pstmt.setInt(1, ctx.getAD_Client_ID());
      pstmt.setInt(2, AD_User_ID);
      pstmt.setInt(3, AD_User_ID);
      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.closeResultSet(rs);
      DB.closeStatement(pstmt);
    }
    MGoal[] retValue = new MGoal[list.size()];
    list.toArray(retValue);
    return retValue;
  } //	getUserGoals
Example #25
0
  private void fill_combo() {
    try {
      String sql = "select distinct townname from towntrends.trends ";
      pst = conn.prepareStatement(sql);
      rs = pst.executeQuery();

      while (rs.next()) {
        String name = rs.getString("townname");
        jComboBox1.addItem(name);
      }
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(null, ex);
    } finally {
      try {
        pst.close();
        rs.close();
      } catch (Exception ex) {

      }
    }
  }
 public synchronized void updateThumbnail(
     String name, long modified, int type, DLNAMediaInfo media) {
   Connection conn = null;
   PreparedStatement ps = null;
   try {
     conn = getConnection();
     ps = conn.prepareStatement("UPDATE FILES SET THUMB = ? WHERE FILENAME = ? AND MODIFIED = ?");
     ps.setString(2, name);
     ps.setTimestamp(3, new Timestamp(modified));
     if (media != null) {
       ps.setBytes(1, media.getThumb());
     } else {
       ps.setNull(1, Types.BINARY);
     }
     ps.executeUpdate();
   } catch (SQLException se) {
     if (se.getErrorCode() == 23001) {
       LOGGER.debug(
           "Duplicate key while inserting this entry: "
               + name
               + " into the database: "
               + se.getMessage());
     } else {
       LOGGER.error(null, se);
     }
   } finally {
     close(ps);
     close(conn);
   }
 }
  /**
   * verifica si hay productos asociados
   *
   * @param table table
   */
  private boolean verify() {
    String sql =
        "SELECT XX_VMR_ReferenceMatrix_ID "
            + "FROM XX_VMR_ReferenceMatrix "
            + "WHERE XX_VMR_PO_LINEREFPROV_ID="
            + (Integer) LineRefProv.getXX_VMR_PO_LineRefProv_ID();

    PreparedStatement pstmt = null;
    ResultSet rs = null;

    try {
      pstmt = DB.prepareStatement(sql, null);
      rs = pstmt.executeQuery();

      while (rs.next()) {
        associatedReference_ID = rs.getInt("XX_VMR_ReferenceMatrix_ID");
        rs.close();
        pstmt.close();
        return true;
      }

    } catch (SQLException e) {
      log.log(Level.SEVERE, sql, e);
    } finally {

      try {
        rs.close();
      } catch (SQLException e1) {
        e1.printStackTrace();
      }
      try {
        pstmt.close();
      } catch (SQLException e) {
        e.printStackTrace();
      }
    }

    return false;
  } //  tableLoad
Example #28
0
  public void incluiIniciado(Connection conn, JobIniciado job) throws SQLException {

    String sql =
        "insert into jobsiniciados(job, operacao, data, tripulacao, ativo, recurso) values(?,?,?,?,?,?) ";
    PreparedStatement stmt = null;

    stmt = conn.prepareStatement(sql);
    stmt.setString(1, job.getJob().trim().replace(".", ""));
    stmt.setInt(2, job.getOperacao());
    stmt.setTimestamp(3, Validacoes.converteDataStringEmFormatoTimeStamp(job.getData().trim()));
    stmt.setDouble(4, job.getTripulacao());
    stmt.setBoolean(5, true);
    stmt.setString(6, job.getRecurso().trim());
    stmt.executeUpdate();
  }
  private boolean isInMatrix() {

    String SQL =
        "Select * "
            + "from XX_VMR_REFERENCEMATRIX "
            + "where XX_VMR_PO_LINEREFPROV_ID="
            + LineRefProv.get_ID();

    PreparedStatement pstmt = null;
    ResultSet rs = null;

    try {
      pstmt = DB.prepareStatement(SQL, null);
      rs = pstmt.executeQuery();

      while (rs.next()) {
        return true;
      }

    } catch (Exception a) {
      log.log(Level.SEVERE, SQL, a);
    } finally {

      try {
        rs.close();
      } catch (SQLException e1) {
        e1.printStackTrace();
      }
      try {
        pstmt.close();
      } catch (SQLException e) {
        e.printStackTrace();
      }
    }

    return false;
  }
Example #30
0
  public void alteraIniciado(Connection conn, JobIniciado job) throws SQLException {

    String sql =
        " update jobsiniciados set data = ?, ativo = ?, tripulacao = ?, recurso = ?  "
            + "    where job = ? and operacao = ? ";
    PreparedStatement stmt = null;

    stmt = conn.prepareStatement(sql);

    stmt.setTimestamp(1, Validacoes.converteDataStringEmFormatoTimeStamp(job.getData().trim()));
    stmt.setBoolean(2, true);
    stmt.setDouble(3, job.getTripulacao());
    stmt.setString(4, job.getRecurso().trim());
    stmt.setString(5, job.getJob().trim().replace(".", ""));
    stmt.setInt(6, job.getOperacao());
    stmt.executeUpdate();
  }