Examples of HPreparedStatement


Examples of org.apache.hadoop.hbase.hbql.client.HPreparedStatement

    }

    private static void insertRecords(final HConnection connection,
                                      final int cnt) throws HBqlException {

        HPreparedStatement stmt = connection.prepareStatement("insert into tab4 " +
                                                              "(keyval, val1, val2, val3, val4) values " +
                                                              "(:key, :val1, :val2, :val3, :val4)");

        for (int i = 0; i < cnt; i++) {

            int val = 10 + i;

            final String keyval = Util.getZeroPaddedNonNegativeNumber(i, 15);

            stmt.setParameter("key", keyval);
            stmt.setParameter("val1", Util.getZeroPaddedNonNegativeNumber(val * 100, 15));
            stmt.setParameter("val2", val);
            stmt.setParameter("val3", randomVal.nextInt());
            stmt.setParameter("val4", (i % 2) == 0);
            stmt.execute();
        }
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HPreparedStatement

    }

    private static void insertRecords(final HConnection connection,
                                      final int cnt) throws HBqlException {

        HPreparedStatement stmt = connection.prepareStatement("insert into tab3 " +
                                                              "(keyval, val1, val2, val3) values " +
                                                              "(:key, :val1, :val2, DEFAULT)");

        for (int i = 0; i < cnt; i++) {

            int val = 10 + i;

            final String keyval = Util.getZeroPaddedNonNegativeNumber(i, TestSupport.keywidth);

            stmt.setParameter("key", keyval);
            stmt.setParameter("val1", "" + val);
            stmt.setParameter("val2", val);
            stmt.execute();
        }
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HPreparedStatement

        else if (this.getSystemMappingsMap().get(mappingName) != null)
            return true;
        else {
            // Do not check cached mappings map, go to the server for answer
            final String sql = "SELECT mapping_name FROM " + SYSTEM_MAPPINGS + " WITH KEYS ?";
            final HPreparedStatement stmt = this.getConnection().prepareStatement(sql);
            ((HStatementImpl)stmt).setIgnoreQueryExecutor(true);
            stmt.setParameter(1, mappingName);
            final List<HRecord> recs = stmt.executeQueryAndFetch();
            stmt.close();
            final boolean retval = recs.size() > 0;

            if (!retval) {
                // Remove from cached mappings map if it was dropped by another user
                if (this.getCachedMappingsMap().containsKey(mappingName))
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HPreparedStatement

            // Remove from cached mappings map
            if (this.getCachedMappingsMap().containsKey(mappingName))
                this.getCachedMappingsMap().remove(mappingName);

            final String sql = "DELETE FROM " + SYSTEM_MAPPINGS + " WITH KEYS ?";
            final HPreparedStatement stmt = this.getConnection().prepareStatement(sql);
            stmt.setParameter(1, mappingName);
            final int cnt = stmt.executeUpdate().getCount();
            return cnt > 0;
        }
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HPreparedStatement

        }
        else {
            this.getCachedMappingsMap().put(mappingName, tableMapping);

            final String sql = "INSERT INTO " + SYSTEM_MAPPINGS + " (mapping_name, mapping_obj) VALUES (?, ?)";
            final HPreparedStatement stmt = this.getConnection().prepareStatement(sql);
            stmt.setParameter(1, tableMapping.getMappingName());
            stmt.setParameter(2, tableMapping);
            stmt.execute();
        }

        return tableMapping;
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HPreparedStatement

        else if (this.getCachedMappingsMap().containsKey(mappingName)) {
            return this.getCachedMappingsMap().get(mappingName);
        }
        else {
            final String sql = "SELECT mapping_obj FROM " + SYSTEM_MAPPINGS + " WITH KEYS ?";
            final HPreparedStatement stmt = this.getConnection().prepareStatement(sql);
            stmt.setParameter(1, mappingName);
            List<HRecord> recs = stmt.executeQueryAndFetch();

            if (recs.size() == 0)
                throw new HBqlException("Mapping not found: " + mappingName);
            else
                return (TableMapping)recs.get(0).getCurrentValue("mapping_obj");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.