Example usage for java.sql Types VARCHAR

List of usage examples for java.sql Types VARCHAR

Introduction

In this page you can find the example usage for java.sql Types VARCHAR.

Prototype

int VARCHAR

To view the source code for java.sql Types VARCHAR.

Click Source Link

Document

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type VARCHAR.

Usage

From source file:ar.com.zauber.commons.gis.spots.impl.SQLGeonameSpotDAO.java

/** @see GeonameSpotDAO#getSpotsWithNameLike(String) */
public final Collection<GeonameSpot> getSpotsWithNameLike(final String name, final Paging paging) {
    String ansiname = LatinStringUtils.replaceAccents(name);
    String sql = SELECT_WHAT + " WHERE ansiname ~* ? ORDER BY ansiname";
    Object[] objs;//from   ww  w.j  a v a2s  .  c  o m
    int[] classes;

    if (paging == null) {
        objs = new Object[] { ansiname };
        classes = new int[] { Types.VARCHAR };
    } else {
        sql += " LIMIT ? OFFSET ?";
        objs = new Object[] { ansiname, paging.getResultsPerPage(), paging.getFirstResult() };
        classes = new int[] { Types.VARCHAR, Types.INTEGER, Types.INTEGER };

        if (paging.loadResultSize()) {
            paging.setResultSize((int) getCountSpotsWithNameLike(ansiname));
        }
    }

    return (Collection<GeonameSpot>) jdbcTemplate.query(sql, objs, classes,
            new GeonameSpotExtractor(wktReader));
}

From source file:org.smigo.user.JdbcUserDao.java

@Override
public void deleteOpenId(String openIdUrl) {
    String sql = "DELETE FROM openid WHERE identity_url = ?";
    jdbcTemplate.update(sql, new Object[] { openIdUrl }, new int[] { Types.VARCHAR });
}

From source file:org.voltdb.example.springjdbc.ContestantDao.java

public int deleteContestant(String code) {
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("code", new SqlParameterValue(Types.VARCHAR, code));
    return update(deleteByCode, params);
}

From source file:ar.com.zauber.commons.repository.utils.URIUserType.java

/**
 * @see UserType#nullSafeSet(PreparedStatement, Object, int)
 * @throws HibernateException//www  . j  av  a 2s . c  o  m
 *             on error
 * @throws SQLException
 *             on error
 */
public final void nullSafeSet(final PreparedStatement st, final Object value, final int index)
        throws HibernateException, SQLException {
    Validate.notNull(st);
    Validate.isTrue(value == null || value instanceof URI);
    if (value == null) {
        st.setNull(index, Types.VARCHAR);
    } else {
        st.setString(index, ((URI) value).toString());
    }

}

From source file:com.agiletec.aps.system.services.authorization.AuthorizationDAO.java

protected void addUserAuthorizations(String username, List<Authorization> authorizations, Connection conn) {
    PreparedStatement stat = null;
    try {//w  ww.  j a v a  2s  .  co  m
        stat = conn.prepareStatement(ADD_AUTHORIZATION);
        for (int i = 0; i < authorizations.size(); i++) {
            Authorization auth = authorizations.get(i);
            if (null == auth)
                continue;
            stat.setString(1, username);
            if (null != auth.getGroup()) {
                stat.setString(2, auth.getGroup().getName());
            } else {
                stat.setNull(2, Types.VARCHAR);
            }
            if (null != auth.getRole()) {
                stat.setString(3, auth.getRole().getName());
            } else {
                stat.setNull(3, Types.VARCHAR);
            }
            stat.addBatch();
            stat.clearParameters();
        }
        stat.executeBatch();
    } catch (Throwable t) {
        _logger.error("Error detected while addind user authorizations", t);
        throw new RuntimeException("Error detected while addind user authorizations", t);
    } finally {
        this.closeDaoResources(null, stat);
    }
}

From source file:com.adaptris.core.services.jdbc.types.StringColumnTranslatorTest.java

@Test
public void testAsFormattedDoubleTranslator() throws Exception {
    translator.setFormat("%f");
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", new Double(111), Types.VARCHAR);
    {/*from   w  w w.ja  va  2 s  . co m*/
        String translated = translator.translate(row, 0);
        assertEquals("111.000000", translated);
    }
    {
        String translated = translator.translate(row, "testField");
        assertEquals("111.000000", translated);
    }
}

From source file:com.streamsets.pipeline.stage.it.PartialInputIT.java

@Test
public void testPartialInput() throws Exception {
    HiveMetadataProcessor processor = new HiveMetadataProcessorBuilder()
            .partitions(Collections.<PartitionConfig>emptyList()).build();
    HiveMetastoreTarget hiveTarget = new HiveMetastoreTargetBuilder().build();

    List<Record> records = new LinkedList<>();
    Record record;/* www. j a  va 2s  .  c  o  m*/

    record = RecordCreator.create("s", "s:1");
    record.set(
            Field.create(Field.Type.MAP, ImmutableSortedMap.of("id", Field.create(Field.Type.STRING, "text"))));
    records.add(record);

    record = RecordCreator.create("s", "s:2");
    record.set(Field.create(Field.Type.MAP,
            ImmutableSortedMap.of("name", Field.create(Field.Type.STRING, "text"))));
    records.add(record);

    record = RecordCreator.create("s", "s:3");
    record.set(Field.create(Field.Type.MAP,
            ImmutableSortedMap.of("value", Field.create(Field.Type.STRING, "text"))));
    records.add(record);

    record = RecordCreator.create("s", "s:4");
    record.set(Field.create(Field.Type.MAP, ImmutableSortedMap.of("value",
            Field.create(Field.Type.STRING, "text"), "id", Field.create(Field.Type.STRING, "text"))));
    records.add(record);

    record = RecordCreator.create("s", "s:5");
    record.set(Field.create(Field.Type.MAP, ImmutableSortedMap.of("name",
            Field.create(Field.Type.STRING, "text"), "id", Field.create(Field.Type.STRING, "text"))));
    records.add(record);

    processRecords(processor, hiveTarget, records);

    // End state should be with three columns
    assertTableStructure("default.tbl", new ImmutablePair("tbl.id", Types.VARCHAR),
            new ImmutablePair("tbl.name", Types.VARCHAR), new ImmutablePair("tbl.value", Types.VARCHAR));

    // 5 rows
    assertQueryResult("select count(*) from tbl", new QueryValidator() {
        @Override
        public void validateResultSet(ResultSet rs) throws Exception {
            Assert.assertTrue(rs.next());
            Assert.assertEquals(5, rs.getInt(1));
            Assert.assertFalse(rs.next());
        }
    });

    // And 4 files
    Assert.assertEquals(3, getDefaultFileSystem().listStatus(new Path("/user/hive/warehouse/tbl/")).length);
}

From source file:com.cisco.dvbu.ps.utils.net.FtpFile.java

public ParameterInfo[] getParameterInfo() {
    return new ParameterInfo[] { new ParameterInfo("fileName", Types.VARCHAR, DIRECTION_IN),
            new ParameterInfo("hostIp", Types.VARCHAR, DIRECTION_IN),
            new ParameterInfo("userId", Types.VARCHAR, DIRECTION_IN),
            new ParameterInfo("userPass", Types.VARCHAR, DIRECTION_IN),
            new ParameterInfo("ftpDirName", Types.VARCHAR, DIRECTION_IN),
            new ParameterInfo("dirName", Types.VARCHAR, DIRECTION_IN),
            new ParameterInfo("success", Types.BOOLEAN, DIRECTION_OUT) };
}

From source file:com.streamsets.pipeline.stage.destination.hive.HiveMetastoreTargetIT.java

@Test
public void testCreateNonExistingTable() throws Exception {
    HiveMetastoreTarget hiveTarget = new HiveMetastoreTargetBuilder().build();

    TargetRunner runner = new TargetRunner.Builder(HiveMetastoreTarget.class, hiveTarget)
            .setOnRecordError(OnRecordError.STOP_PIPELINE).build();
    runner.runInit();/*from   w w  w  . j a  va2s  .  c om*/

    LinkedHashMap<String, HiveTypeInfo> columns = new LinkedHashMap<>();
    columns.put("name", HiveType.STRING.getSupport().generateHiveTypeInfoFromResultSet("STRING"));

    LinkedHashMap<String, HiveTypeInfo> partitions = new LinkedHashMap<>();
    partitions.put("dt", HiveType.STRING.getSupport().generateHiveTypeInfoFromResultSet("STRING"));

    Field newTableField = HiveMetastoreUtil.newSchemaMetadataFieldBuilder("default", "tbl", columns, partitions,
            true, BaseHiveIT.getDefaultWareHouseDir(), HiveMetastoreUtil.generateAvroSchema(columns, "tbl"));

    Record record = RecordCreator.create();
    record.set(newTableField);
    Assert.assertTrue(HiveMetastoreUtil.isSchemaChangeRecord(record));

    runner.runWrite(ImmutableList.of(record));
    runner.runDestroy();

    assertTableStructure("default.tbl", new ImmutablePair("tbl.name", Types.VARCHAR),
            new ImmutablePair("tbl.dt", Types.VARCHAR));
}

From source file:net.navasoft.madcoin.backend.services.security.UserEmailMapper.java

/**
 * Gets the authorities.//from   www.  j  av a 2s .com
 * 
 * @param username
 *            the username
 * @return the authorities
 * @since 17/08/2014, 06:20:43 PM
 */
private Collection<? extends GrantedAuthority> getAuthorities(String username) {
    String key = AccessProperties.AUTHORITY_QUERY.getConfigKey();
    if (initializer.containsKey(key)) {
        mapping.addValue("username", username, Types.VARCHAR);
        return dao.query(initializer.getProperty(key), mapping, authorityMapper);
    } else {
        throw new BadConfigException("Query is not defined.");
    }
}