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:egovframework.rte.fdl.security.userdetails.jdbc.EgovUsersByUsernameMapping.java

/**
 * ? ??  ??? .//  w  w  w  .j  av a 2s . c o  m
 * @param ds
 * @param usersByUsernameQuery
 */
public EgovUsersByUsernameMapping(DataSource ds, String usersByUsernameQuery) {
    super(ds, usersByUsernameQuery);
    declareParameter(new SqlParameter(Types.VARCHAR));
    compile();
}

From source file:demo.repository.DemoProcedure.java

/**
 * Executes {@code GREPO_DEMO.DEMO_FUNCTION}.
 *
 * @param param1 The p_string param.//from w w  w . j a va 2s .c o m
 * @param param2 The p_integer param.
 * @return Returns the p_result.
 */
@GenericProcedure(sql = "grepo_demo.demo_function", returnParamName = "p_result", function = true)
@Out(name = "p_result", sqlType = Types.VARCHAR)
String executeDemoFunction(@In(name = "p_string", sqlType = Types.VARCHAR) String param1,
        @In(name = "p_integer", sqlType = Types.INTEGER) int param2);

From source file:Spring.Repaso02.ClienteDAO.java

@Override
public Cliente consulta(String idCliente) {
    String selQuery = "select * from TClientes where idCliente = ?";
    Cliente cliente = (Cliente) jdbcTemplate.queryForObject(selQuery, new Object[] { idCliente },
            new int[] { Types.VARCHAR }, new BeanPropertyRowMapper(Cliente.class));
    return cliente;
}

From source file:de.drv.dsrv.spoc.dao.SpocConfigDAOImpl.java

@Override
public SPoCConfigDTO selectConfig(final String prozedur, final String datentyp, final String profil,
        final String version) {

    final Object[] arguments = new Object[] { prozedur, datentyp, profil, version };
    final int[] argumentTypen = new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR };

    try {// w  w  w.j a va 2s.c om
        return this.jdbcTemplate.queryForObject(this.selectSql, arguments, argumentTypen, new MyRowMapper());
    } catch (final EmptyResultDataAccessException ex) {
        return null;
    }

}

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

@Parameterized.Parameters(name = "type({0})")
public static Collection<Object[]> data() throws Exception {
    return Arrays.asList(new Object[][] { { Field.create(Field.Type.BOOLEAN, true), true, Types.BOOLEAN, true },
            { Field.create(Field.Type.CHAR, 'A'), true, Types.VARCHAR, "A" },
            { Field.create(Field.Type.BYTE, (byte) 0x00), false, 0, null },
            { Field.create(Field.Type.SHORT, 10), true, Types.INTEGER, 10 },
            { Field.create(Field.Type.INTEGER, 10), true, Types.INTEGER, 10 },
            { Field.create(Field.Type.LONG, 10), true, Types.BIGINT, 10L },
            { Field.create(Field.Type.FLOAT, 1.5), true, Types.FLOAT, 1.5 },
            { Field.create(Field.Type.DOUBLE, 1.5), true, Types.DOUBLE, 1.5 },
            { Field.create(Field.Type.DATE, new Date(116, 5, 13)), true, Types.DATE, new Date(116, 5, 13) },
            { Field.create(Field.Type.DATETIME, date), true, Types.VARCHAR, datetimeFormat.format(date) },
            { Field.create(Field.Type.TIME, date), true, Types.VARCHAR, timeFormat.format(date) },
            { Field.create(Field.Type.DECIMAL, BigDecimal.valueOf(1.5)), true, Types.DECIMAL,
                    new BigDecimal(BigInteger.valueOf(15), 1, new MathContext(2, RoundingMode.FLOOR)) },
            { Field.create(Field.Type.STRING, "StreamSets"), true, Types.VARCHAR, "StreamSets" },
            { Field.create(Field.Type.BYTE_ARRAY, new byte[] { (byte) 0x00 }), true, Types.BINARY,
                    new byte[] { (byte) 0x00 } },
            { Field.create(Field.Type.MAP, Collections.emptyMap()), false, 0, null },
            { Field.create(Field.Type.LIST, Collections.emptyList()), false, 0, null },
            { Field.create(Field.Type.LIST_MAP, new LinkedHashMap<>()), false, 0, null }, });
}

From source file:org.gridobservatory.greencomputing.dao.TimeseriesDao.java

public BigInteger insert(T timeseriesType) {
    KeyHolder keyHolder = new GeneratedKeyHolder();

    PreparedStatementCreatorFactory preparedStatementCreatorFactory = new PreparedStatementCreatorFactory(
            "insert into time_series (constant_value,start_date,end_date,acquisition_count ) "
                    + "values (?, ?, ?, ?)",
            new int[] { Types.VARCHAR, Types.TIMESTAMP, Types.TIMESTAMP, Types.BIGINT });

    PreparedStatementCreator newPreparedStatementCreator = preparedStatementCreatorFactory
            .newPreparedStatementCreator(new Object[] {
                    timeseriesType.getConstantValue() != null ? timeseriesType.getConstantValue().getValue()
                            : "",
                    new Date(timeseriesType.getStartDate().longValue() * 1000),
                    new Date(timeseriesType.getEndDate().longValue() * 1000),
                    timeseriesType.getAcquisitionCount() });

    preparedStatementCreatorFactory.setReturnGeneratedKeys(true);
    this.getJdbcTemplate().update(newPreparedStatementCreator, keyHolder);
    BigInteger timeSeriesId = BigInteger.valueOf(keyHolder.getKey().longValue());

    insertTimeSeriesAcquisitions(timeSeriesId, timeseriesType.getA());

    return timeSeriesId;
}

From source file:net.chrisrichardson.bankingExample.domain.jdbc.JdbcAccountDao.java

public void addAccount(Account account) {
    logger.debug("adding account");
    int count = jdbcTemplate.update(
            "INSERT INTO BANK_ACCOUNT(accountId, BALANCE, overdraftPolicy, dateOpened, requiredYearsOpen, limit) values(?, ?, ?, ?, ?, ?)",
            new Object[] { account.getAccountId(), account.getBalance(), account.getOverdraftPolicy(),
                    new Timestamp(account.getDateOpened().getTime()), account.getRequiredYearsOpen(),
                    account.getLimit() },
            new int[] { Types.VARCHAR, Types.DOUBLE, Types.INTEGER, Types.TIMESTAMP, Types.DOUBLE,
                    Types.DOUBLE });
    Assert.isTrue(count == 1);/*from   www .j ava  2  s.co m*/
}

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

@Parameterized.Parameters(name = "type({0})")
public static Collection<Object[]> data() throws Exception {
    return Arrays.asList(new Object[][] {
            // Supported types
            { Field.create(Field.Type.INTEGER, 1), partition(HiveType.INT), true, Types.INTEGER, 1 },
            { Field.create(Field.Type.LONG, 1), partition(HiveType.BIGINT), true, Types.BIGINT, 1L },
            { Field.create(Field.Type.STRING, "value"), partition(HiveType.STRING), true, Types.VARCHAR,
                    "value" },
            // Unsupported types
            { Field.create(Field.Type.BOOLEAN, true), partition(HiveType.BOOLEAN), false, 0, null },
            { Field.create(Field.Type.DATE, new Date()), partition(HiveType.DATE), false, 0, null },
            { Field.create(Field.Type.FLOAT, 1.2), partition(HiveType.FLOAT), false, 0, null },
            { Field.create(Field.Type.DOUBLE, 1.2), partition(HiveType.DOUBLE), false, 0, null },
            { Field.create(Field.Type.BYTE_ARRAY, new byte[] { 0x00 }), partition(HiveType.BINARY), false, 0,
                    null },//from   w  w w  .j  a v a2  s. com
            // Decimal fails with java.lang.ArrayIndexOutOfBoundsException
            //      {Field.create(Field.Type.DECIMAL, BigDecimal.valueOf(1.5)), partition(HiveType.DECIMAL), false, 0, null},
    });
}

From source file:uk.co.blackpepper.support.spring.jdbc.jooq.SpringJdbcJooqUtilsTest.java

@Test
public void getSqlTypesWithParamReturnsSqlType() {
    List<? extends Param<?>> fields = singletonList(param("x", String.class));

    int[] actual = SpringJdbcJooqUtils.getSqlTypes(fields);

    assertThat(actual, is(new int[] { Types.VARCHAR }));
}

From source file:net.sourceforge.vulcan.spring.jdbc.BuildInserter.java

public BuildInserter(DataSource dataSource) {
    setDataSource(dataSource);//from   w w  w .j  a  va 2s .  com
    setSql("insert into builds " + "(project_id, uuid, status, message_key,"
            + "message_arg_0, message_arg_1, message_arg_2, message_arg_3, " + "build_reason_key, "
            + "build_reason_arg_0, build_reason_arg_1, build_reason_arg_2, build_reason_arg_3, "
            + "start_date, completion_date, build_number, update_type,"
            + "work_dir, revision, revision_label, last_good_build_number,"
            + "tag_name, repository_url, status_changed, scheduled_build,"
            + "requested_by, revision_unavailable, broken_by_user_id, claimed_date, work_dir_vcs_clean) "
            + "values ((select id from project_names where name=?),"
            + " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
            + " (select id from users where username=?), ?, ?)");

    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.TIMESTAMP));
    declareParameter(new SqlParameter(Types.TIMESTAMP));
    declareParameter(new SqlParameter(Types.NUMERIC));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.BIGINT));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.NUMERIC));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.BOOLEAN));
    declareParameter(new SqlParameter(Types.BOOLEAN));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.BOOLEAN));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.TIMESTAMP));
    declareParameter(new SqlParameter(Types.BOOLEAN));

    compile();
}