Package com.sun.rowset

Examples of com.sun.rowset.CachedRowSetImpl


            }

            // Need to use a CachedRowSet that caches its rows in memory, which
            // makes it possible to operate without always being connected to
            // its data source
            CachedRowSet rowset = new CachedRowSetImpl();
            rowset.populate(rs);
            return rowset;
        } catch (SQLException ex) {
            throw new DatabaseException(ex.getMessage(), ex);
        } finally {
            safeCloseResultSet(rs);
View Full Code Here


            }

            // Need to use a CachedRowSet that caches its rows in memory, which
            // makes it possible to operate without always being connected to
            // its data source
            CachedRowSet rowset = new CachedRowSetImpl();
            rowset.populate(rs);
            return rowset;
        } catch (SQLException ex) {
            throw new DatabaseException(ex.getMessage(), ex);
        } finally {
            safeCloseResultSet(rs);
View Full Code Here

   * @return a CachedRowSet of the results
   * @throws Exception
   *             if something goes wrong
   */
  public static CachedRowSet fetchRowSet(EOAdaptorChannel adaptorChannel, String query) throws Exception {
    final CachedRowSetImpl rowSet = new CachedRowSetImpl();
    ERXJDBCUtilities.executeQuery(adaptorChannel, query, new IResultSetDelegate() {
      public void processResultSet(EOAdaptorChannel innerAdaptorChannel, ResultSet rs) throws Exception {
        rowSet.populate(rs);
      }
    });
    return rowSet;
  }
View Full Code Here

    }
  }
 
  public void testBug49516() throws Exception {

    CachedRowSetImpl crs;

    createTable(
        "bug49516",
        "(`testingID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `firstName` TEXT NOT NULL) CHARACTER SET utf8;");
    this.stmt.executeUpdate("insert into bug49516 set firstName ='John'");

    this.rs = this.stmt
        .executeQuery("select firstName as 'first person' from bug49516");
    this.rs.first();
    assertEquals("John", this.rs.getString("first person"));
    // this.rs.close();
    // this.stmt.close();
   
   
    this.rs = this.stmt
      .executeQuery("select firstName as 'first person' from bug49516");
   
    crs = new CachedRowSetImpl();
    crs.populate(this.rs);
    crs.first();

    assertEquals("John", crs.getString(1));

  }
View Full Code Here

  }
 
  public void testBug48820() throws Exception {

    CachedRowSetImpl crs;

    Connection noBlobsConn = getConnectionWithProps("functionsNeverReturnBlobs=true");
   
    this.rs = noBlobsConn.createStatement().executeQuery("SELECT PASSWORD ('SOMETHING')");
    this.rs.first();
   
    String fromPlainResultSet = this.rs.getString(1);

    this.rs = noBlobsConn.createStatement().executeQuery("SELECT PASSWORD ('SOMETHING')");

    crs = new CachedRowSetImpl();
    crs.populate(this.rs);
    crs.first();

    assertEquals(fromPlainResultSet, crs.getString(1));

  }
View Full Code Here

         connection = dao_.getExoDatasource().getConnection();
         Statement statement =
            connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
         ResultSet resultSet = statement.executeQuery(query);

         CachedRowSet crs = new CachedRowSetImpl();
         crs.setPageSize(pageList.getPageSize());
         crs.populate(resultSet, (pageList.getCurrentPage() - 1) * pageList.getPageSize() + 1);

         while (crs.next())
         {
            T bean = dao_.createInstance();
            dao_.getDBObjectMapper().mapResultSet(crs, bean);
            currentListPage_.add(bean);
         }
View Full Code Here

        // connect
        Connection conn = getConnection();
        Statement st = null;
        try {
            st = conn.createStatement();
            CachedRowSetImpl crs = new CachedRowSetImpl();
            crs.populate(st.executeQuery(sql));
            return crs;
        } finally {
            st.close();
            conn.close();
        }
View Full Code Here

    Statement st = con.createStatement();

    ResultSet rr = st.executeQuery("SELECT GEOCODE FROM TB_CIDADES WHERE FONETICO LIKE CONCAT('%', fncFonetico('" + city.getName()
        + "'), '%') AND ( UF LIKE '%" + city.getState() + "%' ) AND GEOCODE IS NOT NULL ORDER BY LENGTH(MUNICY) LIMIT 1; ".toUpperCase());

    CachedRowSetImpl crs = new CachedRowSetImpl();
    crs.populate(rr);

    if (crs.size() == 0) {
      st = con.createStatement();
      rr = st.executeQuery("SELECT GEOCODE FROM TB_CIDADES WHERE FONETICO LIKE CONCAT('%', fncFonetico('%" + city.getName()
          + "%'), '%)' AND ( ESTADO like '%" + city.getState()
          + "%' ) AND GEOCODE IS NOT NULL ORDER BY LENGTH(MUNICY) LIMIT 1 ".toUpperCase());

      crs = new CachedRowSetImpl();
      crs.populate(rr);

      if (crs.size() == 0) {
        throw (new Exception("Nao é possivel encontrar endereços dentro desta cidade : " + city.getName() + "-" + city.getState() + "."));
      } else {
        tabelaRuas = crs.getString("GEOCODE");
      }
    } else {
      crs.next();
      tabelaRuas = crs.getString("GEOCODE");
    }

    st = con.createStatement();

    rr = st.executeQuery("show tables like '" + tabelaRuas + "'");
    crs = new CachedRowSetImpl();
    crs.populate(rr);

    if (crs.size() == 0)
      throw (new Exception("Nao foi possivel encontrar esta cidade " + city.getName() + "-" + city.getState() + "."));

    return tabelaRuas;
  }
View Full Code Here

      cst.execute();

      ResultSet rs1 = cst.getResultSet();

      CachedRowSetImpl crs = new CachedRowSetImpl();
      crs.populate(rs1);

      int TotalRecords = crs.size();

      if (TotalRecords > 0) {
        try {
          pg = Functions.definePage(TotalRecords, rr.getRecordsPerPage(), rr.getPageIndex());
          DistrictLocation[] dl;

          if (pg.getRecordsInitial() <= TotalRecords) {
            dl = new DistrictLocation[(pg.getRecordsFinal() - pg.getRecordsInitial()) + 1];

            for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
              // classe district
              if (rs1.absolute(intI)) {
                dl[iCount] = new DistrictLocation();

                dl[iCount].setDistrict(new District());
                dl[iCount].getDistrict().setName(rs1.getString("NOME"));

                dl[iCount].getDistrict().setCity(new City());
                dl[iCount].getDistrict().getCity().setName(rs1.getString("CIDADE"));
                dl[iCount].getDistrict().getCity().setState(rs1.getString("UF"));

                dl[iCount].setPoint(new Point());
                dl[iCount].getPoint().setX(Double.parseDouble(rs1.getString("X")));
                dl[iCount].getPoint().setY(Double.parseDouble(rs1.getString("Y")));

                dl[iCount].getDistrict().setZone(rs1.getString("REGIAO"));

                iCount++;
              }
            }

            ri.setRecordCount((int) pg.getRecordCount());
            ri.setPageCount(pg.getPageCount());
          } else {
            dl = new DistrictLocation[0];
          }

          ri.setDistrictLocation(dl);
        } catch (Exception ex) {
          throw (new Exception("Registro n�o encontrado."));
        }
      } else {
        DistrictLocation[] rl = new DistrictLocation[0];
        ri.setDistrictLocation(rl);
      }

      con.close();
      rs1.close();
      crs.close();
      cst.close();
    } catch (Exception ex) {
      Utils.LogError("CC","findDistrict - IdWebservice : 50", "district.city.name-> " + district.getCity().getName() + " | "
          + "district.city.state -> " + district.getCity().getState() + " | " + "district.name-> " + district.getName() + " | "
          + ex.getMessage() + "|" + ex.getStackTrace());
View Full Code Here

      cst.execute();

      ResultSet rs1 = cst.getResultSet();

      CachedRowSetImpl crs = new CachedRowSetImpl();
      crs.populate(rs1);

      int TotalRecords = crs.size();

      if (TotalRecords > 0) {
        pg = Functions.definePage(TotalRecords, ao.getResultRange().getRecordsPerPage(), ao.getResultRange().getPageIndex());

        if (pg.getRecordsInitial() <= TotalRecords) {
          location = new CityLocation[(pg.getRecordsFinal() - pg.getRecordsInitial()) + 1];

          for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
            if (rs1.absolute(intI)) {
              // definir city
              location[iCount] = new CityLocation();
              location[iCount].setCity(new City());
              location[iCount].getCity().setName(rs1.getString("MUNICY"));
              location[iCount].getCity().setState(rs1.getString("UF"));
              // definir point
              location[iCount].setPoint(new Point());
              location[iCount].getPoint().setX(Double.parseDouble(rs1.getString("X")));
              location[iCount].getPoint().setY(Double.parseDouble(rs1.getString("Y")));
              // definir carAccess
              location[iCount].setCarAccess(true);
              // atribuir CEP
              location[iCount].setZipRangeStart(rs1.getString("CEP_INI"));
              location[iCount].setZipRangeEnd(rs1.getString("CEP_FIM"));
              location[iCount].setCapital(rs1.getBoolean("CAPITAL"));

              location[iCount].setAddressesAvailable(true);

              iCount++;
            }
          }
        } else {
          location = new CityLocation[0];
        }

        cityLocationInfo.setRecordCount((int) pg.getRecordCount());
        cityLocationInfo.setPageCount(pg.getPageCount());
        cityLocationInfo.setCityLocation(location);
      } else {
        location = new CityLocation[0];
        cityLocationInfo.setCityLocation(location);
      }

      con.close();
      rs1.close();
      crs.close();
      cst.close();
    } catch (Exception ex) {
      throw (new Exception("findCity: Falha ao procurar cidades."));
    }
View Full Code Here

TOP

Related Classes of com.sun.rowset.CachedRowSetImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.