示例#1
0
  /** @param props */
  public void initFrame(AppProperties props) {

    m_OS = new OSValidator();
    m_props = props;

    m_rootapp = new JRootApp();

    if (m_rootapp.initApp(m_props)) {

      if ("true".equals(props.getProperty("machine.uniqueinstance"))) {
        // Register the running application
        try {
          m_instmanager = new InstanceManager(this);
        } catch (RemoteException | AlreadyBoundException e) {
        }
      }

      // Show the application
      add(m_rootapp, BorderLayout.CENTER);

      setTitle(AppLocal.APP_NAME + " - V" + AppLocal.APP_VERSION);

      Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
      setBounds(0, 0, d.width, d.height);

      setVisible(true);
    } else {
      new JFrmConfig(props).setVisible(true); // Show the configuration window.
    }
  }
示例#2
0
  public void initFrame(AppProperties props) {

    m_props = props;

    m_rootapp = new JRootApp();

    if (m_rootapp.initApp(m_props)) {

      if ("true".equals(props.getProperty("machine.uniqueinstance"))) {
        // Register the running application
        try {
          m_instmanager = new InstanceManager(this);
        } catch (Exception e) {
        }
      }

      // Show the application
      add(m_rootapp, BorderLayout.CENTER);

      try {
        this.setIconImage(
            ImageIO.read(
                JRootFrame.class.getResourceAsStream("/com/openbravo/images/favicon.png")));
      } catch (IOException e) {
      }
      setTitle(AppLocal.APP_NAME + " - " + AppLocal.APP_VERSION);
      pack();
      setLocationRelativeTo(null);

      setVisible(true);
    } else {
      new JFrmConfig(props).setVisible(true); // Show the configuration window.
    }
  }
示例#3
0
  public void setActiveCash(String sIndex, int iSeq, Date dStart, Date dEnd) {
    m_sActiveCashIndex = sIndex;
    m_iActiveCashSequence = iSeq;
    m_dActiveCashDateStart = dStart;
    m_dActiveCashDateEnd = dEnd;

    m_propsdb.setProperty("activecash", m_sActiveCashIndex);
    m_dlSystem.setResourceAsProperties(m_props.getHost() + "/properties", m_propsdb);
  }
示例#4
0
  public String perform(HttpServletRequest request, HttpServletResponse response) {

    HttpSession session = request.getSession();
    logger.info("MODIFY TASK");
    try {

      /* get parameters from request */
      Integer id = new Integer(request.getParameter(AppProperties.getProperty("modify_id_param")));
      String taskName = request.getParameter(AppProperties.getProperty("modify_name_param"));
      Integer taskParent =
          new Integer(request.getParameter(AppProperties.getProperty("modify_parent_param")));
      Date taskBegin =
          new SimpleDateFormat("yyyy-MM-dd")
              .parse(request.getParameter(AppProperties.getProperty("modify_begin_param")));
      Date taskEnd =
          new SimpleDateFormat("yyyy-MM-dd")
              .parse(request.getParameter(AppProperties.getProperty("modify_end_param")));
      String taskStatus = request.getParameter(AppProperties.getProperty("modify_status_param"));
      String taskUser = request.getParameter(AppProperties.getProperty("modify_user_param"));
      String taskDescr = request.getParameter(AppProperties.getProperty("modify_descr_param"));

      TaskRecord task =
          new TaskRecord(
              id,
              taskName,
              taskParent,
              taskBegin,
              taskEnd,
              taskStatus,
              new EmpRecord(0, taskUser, null, null),
              taskDescr);

      /* verify and modify data in database */
      verifyData(task);
      DAOFactory.getInstance().modifyTask(task);
      setNotifyMessage(session, logger, SUCCESS_MESS, null, "Task modified", null);

    } catch (ParseException ex) {
      setNotifyMessage(
          session,
          logger,
          FAIL_MESS,
          "Modify exception",
          "Incorrect input data. Reason: " + ex.getMessage(),
          ex);
    } catch (TrackerException ex) {
      setNotifyMessage(session, logger, FAIL_MESS, "Modify exception", ex.getMessage(), ex);
    }
    return "/index.jsp"; // redirected page path
  }
  @Test
  public void testLoadProperties() {
    AppProperties appProps =
        propsManager.loadProps(
            Arrays.asList(
                "classpath:resources/test_aws.properties",
                "classpath:resources/test_jdbc.properties"));

    Assert.assertTrue(appProps.isValid());

    Assert.assertEquals(9, appProps.getKnownProperties().size());
    Assert.assertEquals("AKIAJSF6XRIJNJTTTL3Q", appProps.get("aws_access_key"));
    Assert.assertEquals("pmqnweEYvdiw7cvCdTOES48sOUvK1rGvvctBsgsa", appProps.get("aws_secret_key"));
    Assert.assertEquals(12345678, appProps.get("aws_account_id"));
    Assert.assertEquals(Regions.US_EAST_1, appProps.get("aws.region_id"));

    Assert.assertTrue((boolean) appProps.get("JpA_showSqL"));
  }
  public static PaymentGateway getPaymentGateway(AppProperties props) {

    String sReader = props.getProperty("payment.gateway");

    if ("external".equals(sReader)) {
      return new PaymentGatewayExt();
    } else if ("PayPoint / SecPay".equals(sReader)) {
      return new PaymentGatewayPayPoint(props);
    } else if ("AuthorizeNet".equals(sReader)) {
      return new PaymentGatewayAuthorizeNet(props);
    } else if ("La Caixa (Spain)".equals(sReader)) {
      return new PaymentGatewayCaixa(props);
    } else if ("Planetauthorize".equals(sReader)) {
      return new PaymentGatewayPlanetauthorize(props);
    } else if ("Firs Data / LinkPoint / YourPay".equals(sReader)) {
      return new PaymentGatewayLinkPoint(props);
    } else if ("PaymentsGateway.net".equals(sReader)) {
      return new PaymentGatewayPGNET(props);
    } else {
      return null;
    }
  }
示例#7
0
  @Override
  public Boolean initFrame(AppProperties props) {
    m_props = props;

    m_rootapp = new JRootApp();

    if (m_rootapp.initApp(m_props)) {
      if ("true".equals(props.getProperty("machine.uniqueinstance"))) {
        // Register the running application
        try {
          m_instmanager = new InstanceManager(this);
        } catch (Exception e) {
        }
      }

      // Show the application
      add(m_rootapp, BorderLayout.CENTER);

      try {
        this.setIconImage(
            ImageIO.read(
                JRootFrame.class.getResourceAsStream("/com/openbravo/images/favicon.png")));
      } catch (IOException e) {
      }
      setTitle(AppLocal.APP_NAME + " - " + AppLocal.APP_VERSION);

      // pack();
      this.setSize(800, 600); // set size for normal window state
      this.setExtendedState(MAXIMIZED_BOTH);
      setLocationRelativeTo(null);
      super.initFrame(props);
      setVisible(true);
      return true;
    } else {
      return false;
    }
  }
示例#8
0
  public boolean initApp(AppProperties props) {

    m_props = props;
    // setPreferredSize(new java.awt.Dimension(800, 600));

    // support for different component orientation languages.
    applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));

    // Database start
    try {
      session = AppViewConnection.createSession(m_props);
    } catch (BasicException e) {
      JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_DANGER, e.getMessage(), e));
      return false;
    }

    m_dlSystem = (DataLogicSystem) getBean("com.openbravo.pos.forms.DataLogicSystem");

    // Create or upgrade the database if database version is not the expected
    String sDBVersion = readDataBaseVersion();
    if (!AppLocal.APP_VERSION.equals(sDBVersion)) {

      // Create or upgrade database

      String sScript =
          sDBVersion == null
              ? m_dlSystem.getInitScript() + "-create.sql"
              : m_dlSystem.getInitScript() + "-upgrade-" + sDBVersion + ".sql";

      if (JRootApp.class.getResource(sScript) == null) {
        JMessageDialog.showMessage(
            this,
            new MessageInf(
                MessageInf.SGN_DANGER,
                sDBVersion == null
                    ? AppLocal.getIntString(
                        "message.databasenotsupported",
                        session.DB
                            .getName()) // Create script does not exists. Database not supported
                    : AppLocal.getIntString(
                        "message.noupdatescript"))); // Upgrade script does not exist.
        session.close();
        return false;
      } else {
        // Create or upgrade script exists.
        if (JOptionPane.showConfirmDialog(
                this,
                AppLocal.getIntString(
                    sDBVersion == null ? "message.createdatabase" : "message.updatedatabase"),
                AppLocal.getIntString("message.title"),
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE)
            == JOptionPane.YES_OPTION) {

          try {
            BatchSentence bsentence = new BatchSentenceResource(session, sScript);
            bsentence.putParameter("APP_ID", Matcher.quoteReplacement(AppLocal.APP_ID));
            bsentence.putParameter("APP_NAME", Matcher.quoteReplacement(AppLocal.APP_NAME));
            bsentence.putParameter("APP_VERSION", Matcher.quoteReplacement(AppLocal.APP_VERSION));

            java.util.List l = bsentence.list();
            if (l.size() > 0) {
              JMessageDialog.showMessage(
                  this,
                  new MessageInf(
                      MessageInf.SGN_WARNING,
                      AppLocal.getIntString("Database.ScriptWarning"),
                      l.toArray(new Throwable[l.size()])));
            }
          } catch (BasicException e) {
            JMessageDialog.showMessage(
                this,
                new MessageInf(
                    MessageInf.SGN_DANGER, AppLocal.getIntString("Database.ScriptError"), e));
            session.close();
            return false;
          }
        } else {
          session.close();
          return false;
        }
      }
    }

    // Cargamos las propiedades de base de datos
    m_propsdb = m_dlSystem.getResourceAsProperties(m_props.getHost() + "/properties");

    // creamos la caja activa si esta no existe
    try {
      String sActiveCashIndex = m_propsdb.getProperty("activecash");
      Object[] valcash =
          sActiveCashIndex == null ? null : m_dlSystem.findActiveCash(sActiveCashIndex);
      if (valcash == null || !m_props.getHost().equals(valcash[0])) {
        // no la encuentro o no es de mi host por tanto creo una...
        setActiveCash(
            UUID.randomUUID().toString(),
            m_dlSystem.getSequenceCash(m_props.getHost()) + 1,
            new Date(),
            null);

        // creamos la caja activa
        m_dlSystem.execInsertCash(
            new Object[] {
              getActiveCashIndex(),
              m_props.getHost(),
              getActiveCashSequence(),
              getActiveCashDateStart(),
              getActiveCashDateEnd()
            });
      } else {
        setActiveCash(sActiveCashIndex, (Integer) valcash[1], (Date) valcash[2], (Date) valcash[3]);
      }
    } catch (BasicException e) {
      // Casco. Sin caja no hay pos
      MessageInf msg =
          new MessageInf(
              MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotclosecash"), e);
      msg.show(this);
      session.close();
      return false;
    }

    // Leo la localizacion de la caja (Almacen).
    m_sInventoryLocation = m_propsdb.getProperty("location");
    if (m_sInventoryLocation == null) {
      m_sInventoryLocation = "0";
      m_propsdb.setProperty("location", m_sInventoryLocation);
      m_dlSystem.setResourceAsProperties(m_props.getHost() + "/properties", m_propsdb);
    }

    // Inicializo la impresora...
    m_TP = new DeviceTicket(this, m_props);

    // Inicializamos
    m_TTP = new TicketParser(getDeviceTicket(), m_dlSystem);
    printerStart();

    // Inicializamos la bascula
    m_Scale = new DeviceScale(this, m_props);

    // Inicializamos la scanpal
    m_Scanner = DeviceScannerFactory.createInstance(m_props);

    // Leemos los recursos basicos
    BufferedImage imgicon = m_dlSystem.getResourceAsImage("Window.Logo");
    m_jLblTitle.setIcon(imgicon == null ? null : new ImageIcon(imgicon));
    m_jLblTitle.setText(m_dlSystem.getResourceAsText("Window.Title"));

    String sWareHouse;
    try {
      sWareHouse = m_dlSystem.findLocationName(m_sInventoryLocation);
    } catch (BasicException e) {
      sWareHouse = null; // no he encontrado el almacen principal
    }

    // Show Hostname, Warehouse and URL in taskbar
    String url;
    try {
      url = session.getURL();
    } catch (SQLException e) {
      url = "";
    }
    m_jHost.setText("<html>" + m_props.getHost() + " - " + sWareHouse + "<br>" + url);

    showLogin();

    return true;
  }
示例#9
0
/** @author tatianag */
@SearchProcessorImpl(
    id = "LSSTCatalogQuery",
    params = {
      @ParamDoc(name = "RequestedDataSet", desc = "catalog table to query"),
      @ParamDoc(name = "UserTargetWorldPt", desc = "the target point, a serialized WorldPt object"),
      @ParamDoc(name = "radius", desc = "radius in degrees for cone search"),
      @ParamDoc(name = "size", desc = "size in degrees for box search"),
      @ParamDoc(
          name = CatalogRequest.SELECTED_COLUMNS,
          desc = "a comma separated list of columns to return, empty gives the default list"),
      @ParamDoc(
          name = CatalogRequest.CONSTRAINTS,
          desc = "a where fragment of the column constrains")
    })
public class QueryLSSTCatalog extends IpacTablePartProcessor {
  private static final Logger.LoggerImpl _log = Logger.getLogger();

  private static String QSERV_URI = AppProperties.getProperty("lsst.qserv.uri");
  private static String QSERV_USER = AppProperties.getProperty("lsst.qserv.user");
  private static String QSERV_PASS = AppProperties.getProperty("lsst.qserv.pass");

  private static final String RA_COL = "ra";
  private static final String DEC_COL = "decl";

  @Override
  protected File loadDataFile(TableServerRequest request) throws IOException, DataAccessException {

    File file = createFile(request);

    WorldPt pt = request.getWorldPtParam(ServerParams.USER_TARGET_WORLD_PT);
    pt = VisUtil.convertToJ2000(pt);
    doGetData(file, request.getParams(), pt);
    return file;
  }

  // qserv_areaspec_circle does not work at the moment, only qserv_areaspec_box works
  void doGetData(File oFile, List<Param> params, WorldPt wpt) throws DataAccessException {
    DbInstance dbinstance =
        new DbInstance(
            false, // pooled
            "null", // datasourcePath
            QSERV_URI, // dbUrl
            QSERV_USER,
            StringUtils.isEmpty(QSERV_PASS) ? null : QSERV_PASS,
            "com.mysql.jdbc.Driver",
            "lsstdb");
    DataSource ds = JdbcFactory.getDataSource(dbinstance);

    String searchMethod = null;
    String catTable = null;
    String selectedColumns = null;
    String[] constraints = null;
    for (Param p : params) {
      String pname = p.getName();
      if (pname.equals(CatalogRequest.SEARCH_METHOD)) {
        searchMethod = p.getValue();
      } else if (pname.equals(ServerParams.REQUESTED_DATA_SET)) {
        catTable = p.getValue();
      } else if (pname.equals(CatalogRequest.SELECTED_COLUMNS)) {
        selectedColumns = p.getValue();
      } else if (pname.equals(CatalogRequest.CONSTRAINTS)) {
        String val = p.getValue();
        if (!StringUtils.isEmpty(val)) {
          _log.briefDebug("CONSTRAINTS: " + val);
          constraints = val.split(",");
        }
      }
    }

    String update = getSelectedColumnsUpdate(selectedColumns);
    if (update != null) selectedColumns = update;

    String pname;
    String sql;
    if (searchMethod != null && searchMethod.equals(CatalogRequest.Method.CONE.getDesc())) {
      double radius = 0.0;
      for (Param p : params) {
        pname = p.getName();
        if (pname.equals(CatalogRequest.RADIUS)) {
          radius = Double.parseDouble(p.getValue());
        }
      }
      // qserv_areaspec_circle(ra, dec, radius)
      // sql="select * from "+catTable+" where qserv_areaspec_circle("+wpt.getLon()+",
      // "+wpt.getLat()+", "+radius+")";
      // Per Serge, the above query only can not be applied to unpartitioned table
      sql =
          "select "
              + selectedColumns
              + " from "
              + catTable
              + " where scisql_s2PtInCircle(ra, decl, "
              + wpt.getLon()
              + ", "
              + wpt.getLat()
              + ", "
              + radius
              + ")=1";
    } else if (searchMethod != null && searchMethod.equals(CatalogRequest.Method.BOX.getDesc())) {
      double size = 0.0;
      for (Param p : params) {
        pname = p.getName();
        if (pname.equals(CatalogRequest.SIZE)) {
          size = Double.parseDouble(p.getValue());
        }
      }
      double halfsize = size / 2.0;
      double lon1 = wpt.getLon() - halfsize;
      if (lon1 < 0) lon1 += 360;
      double lon2 = wpt.getLon() + halfsize;
      if (lon2 > 360) lon1 -= 360;
      double lat1 = wpt.getLat() - halfsize;
      if (lat1 < -90) lat1 = -180 - lat1;
      double lat2 = wpt.getLat() + halfsize;
      if (lat2 > 90) lat2 = 180 - lat2;

      // qserv_areaspec_box(raA, decA, raB, decB)
      // sql="select * from "+catTable+" where qserv_areaspec_box("+lon1+", "+lat1+", "+lon2+",
      // "+lat2+")";
      // Per Serge, the above query only can not be applied to unpartitioned table
      sql =
          "select * from "
              + catTable
              + " where scisql_s2PtInBox(ra, decl, "
              + lon1
              + ", "
              + lat1
              + ", "
              + lon2
              + ", "
              + lat2
              + ")=1";

    } else {
      throw new RuntimeException(searchMethod + " search is not Implemented");
    }

    // add additional constraints
    if (constraints != null) {
      for (String constr : constraints) {
        sql += " and " + constr;
      }
    }

    // workaround for https://jira.lsstcorp.org/browse/DM-1841
    sql += " LIMIT 3000";

    Connection conn = null;
    Statement stmt = null;
    try {
      conn = DataSourceUtils.getConnection(ds);
      long cTime = System.currentTimeMillis();
      stmt = conn.createStatement();
      _log.briefDebug("Executing SQL query: " + sql);
      // ResultSet rs = stmt.executeQuery(sql);
      IpacTableExtractor.query(null, ds, oFile, 10000, sql);
      _log.briefDebug("SELECT took " + (System.currentTimeMillis() - cTime) + "ms");
    } catch (Exception e) {
      _log.error(e);
      throw new DataAccessException("Query failed: " + e.getMessage());
    } finally {
      if (stmt != null) {
        try {
          closeStatement(stmt);
        } catch (Exception e1) {
        }
      }
      if (conn != null) {
        DataSourceUtils.releaseConnection(conn, ds);
      }
    }
  }

  @Override
  public void prepareTableMeta(TableMeta meta, List<DataType> columns, ServerRequest request) {
    super.prepareTableMeta(meta, columns, request);

    TableMeta.LonLatColumns llc = new TableMeta.LonLatColumns(RA_COL, DEC_COL); // J2000 default
    meta.setLonLatColumnAttr(MetaConst.CATALOG_COORD_COLS, llc);
    meta.setCenterCoordColumns(llc);

    String title = request.getParam(ServerParams.REQUESTED_DATA_SET);
    title = (title == null) ? "LSST" : "LSST " + title;
    meta.setAttribute(MetaConst.CATALOG_OVERLAY_TYPE, title);
    meta.setAttribute(MetaConst.DATA_PRIMARY, "False");

    setColumnTips(meta, request);
  }

  private static String getSelectedColumnsUpdate(String selectedColumns) {
    String update = null;
    if (StringUtils.isEmpty(selectedColumns)) {
      return "*";
    } else {
      boolean hasRa = false, hasDec = false;
      String[] cols = selectedColumns.split(",");
      for (String col : cols) {
        if (col.equalsIgnoreCase(RA_COL)) {
          hasRa = true;
          if (hasDec) break;
        } else if (col.equalsIgnoreCase(DEC_COL)) {
          hasDec = true;
          if (hasRa) break;
        }
      }
      if (!hasRa) {
        update = selectedColumns + ",ra";
      }
      if (!hasDec) {
        update = (update == null ? selectedColumns : update) + ",decl";
      }
      return update;
    }
  }

  static void closeStatement(Statement stmt) {
    if (stmt != null) {
      try {
        stmt.close();
      } catch (Throwable th) {
        // log and ignore
        _log.warn(th, "Failed to close statement: " + th.getMessage());
      }
    }
  }

  protected void setColumnTips(TableMeta meta, ServerRequest request) {

    TableServerRequest req = new TableServerRequest("LSSTCatalogDD");
    req.setPageSize(1000);
    req.setParam(CatalogRequest.CATALOG, request.getParam(ServerParams.REQUESTED_DATA_SET));

    SearchManager sm = new SearchManager();
    DataGroupPart dgp = new DataGroupPart();

    try {
      dgp = sm.getDataGroup(req);
    } catch (Exception e) {
    }

    DataGroup dg = dgp.getData();
    if (dg != null) {
      for (int i = 0; i < dg.size(); i++) {
        DataObject dObj = dg.get(i);
        String tipStr = "";

        String descStr = (String) dObj.getDataElement("description");
        if (!StringUtils.isEmpty(descStr) && !descStr.equalsIgnoreCase("null")) {
          tipStr += descStr;
        }

        String unitStr = (String) dObj.getDataElement("unit");
        if (!StringUtils.isEmpty(unitStr) && !unitStr.equalsIgnoreCase("null")) {
          if (tipStr.length() > 0) {
            tipStr += " ";
          }
          tipStr += "(" + unitStr + ")";
        }

        String nameStr = (String) dObj.getDataElement("name");
        meta.setAttribute(makeAttribKey(DESC_TAG, nameStr.toLowerCase()), tipStr);
      }
    }
  }

  public static void main(String[] args) {
    DbInstance dbinstance =
        new DbInstance(
            false, // pooled
            "null", // datasourcePath
            "<REPLACE_WITH_DB_URL>", // dbUrl
            "qsmaster",
            null,
            "com.mysql.jdbc.Driver",
            "lsstdb");
    DataSource ds = JdbcFactory.getDataSource(dbinstance);

    String sql = "select * from DeepSource where qserv_areaspec_box(0.4, 1.05, 0.5, 1.15)";

    Connection conn = null;
    try {
      conn = DataSourceUtils.getConnection(ds);
      long cTime = System.currentTimeMillis();

      Statement stmt = null;
      try {
        stmt = conn.createStatement();
        _log.briefDebug("Executing SQL query: " + sql);
        // ResultSet rs = stmt.executeQuery(sql);
        // _log.briefDebug ("SELECT took "+(System.currentTimeMillis()-cTime)+"ms");
        File file = new File("/tmp/lsstTest.tbl");
        IpacTableExtractor.query(null, ds, file, 10000, sql);
        _log.briefDebug("SELECT took " + (System.currentTimeMillis() - cTime) + "ms");
      } catch (Exception e) {
        System.out.println("Exception " + e.getMessage());
      } finally {
        closeStatement(stmt);
      }

    } catch (Exception e) {
      System.out.println("Exception " + e.getMessage());
      e.printStackTrace();
    } finally {
      if (conn != null) {
        DataSourceUtils.releaseConnection(conn, ds);
      }
    }
  }
}
 @Test
 public void testLoadPropertiesWithInvalidFiles() {
   AppProperties appProps = propsManager.loadProps(Arrays.asList("classpath:resources/XYZ"));
   Assert.assertEquals(0, appProps.getKnownProperties().size());
 }
示例#11
0
public class ExcelLibrary {
  AppProperties sp = new AppProperties();
  String path1 = sp.getExcelPath();

  public HashMap<String, String> getExcel(String sheetName) throws Exception {
    HashMap<String, String> returnData = new HashMap<String, String>();
    FileInputStream fis = new FileInputStream(path1);
    Workbook wb = WorkbookFactory.create(fis);
    Sheet s = wb.getSheet(sheetName);
    int rowCount = getRowCount(sheetName);

    for (int i = 0; i <= rowCount; i++) {
      String keyName = "";
      String keyValue = "";
      Row r = s.getRow(i);
      Cell c1 = r.getCell(0);
      keyName = c1.getStringCellValue();
      Cell c2 = r.getCell(1);
      keyValue = c2.getStringCellValue();
      returnData.put(keyName, keyValue);
    }

    return returnData;
  }

  public String getExcelData(String sheetName, int rowNum, int colNum) {
    String retVal = null;
    try {
      FileInputStream fis = new FileInputStream(path1);
      Workbook wb = WorkbookFactory.create(fis);
      Sheet s = wb.getSheet(sheetName);
      Row r = s.getRow(rowNum);
      Cell c = r.getCell(colNum);
      retVal = c.getStringCellValue();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (InvalidFormatException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return retVal;
  }

  public int getRowCount(String sheetName) {
    int retVal = 0;
    try {
      FileInputStream fis = new FileInputStream(path1);
      Workbook wb = WorkbookFactory.create(fis);
      Sheet s = wb.getSheet(sheetName);
      retVal = s.getLastRowNum();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (InvalidFormatException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return retVal;
  }

  public void writeToExcel(String sheetName, int rowNum, int colNum, String desc) {
    try {
      FileInputStream fis = new FileInputStream(path1);
      Workbook wb = WorkbookFactory.create(fis);
      Sheet s = wb.getSheet(sheetName);
      Row r = s.getRow(rowNum);
      Cell c = r.createCell(colNum);
      c.setCellValue(desc);
      FileOutputStream fos = new FileOutputStream(path1);
      wb.write(fos);
      fos.close();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (InvalidFormatException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}