Example usage for java.sql Types CHAR

List of usage examples for java.sql Types CHAR

Introduction

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

Prototype

int CHAR

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

Click Source Link

Document

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

Usage

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

public MetricInserter(DataSource dataSource) {
    setDataSource(dataSource);/*from w  w  w. ja  v  a2 s. co  m*/
    setSql("insert into metrics " + "(build_id, message_key, metric_type, data) " + "values (?, ?, ?, ?)");

    declareParameter(new SqlParameter(Types.NUMERIC));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.CHAR));
    declareParameter(new SqlParameter(Types.VARCHAR));

    compile();
}

From source file:org.apache.ctakes.ytex.kernel.dao.SortedSetUserType.java

public int[] sqlTypes() {
    return new int[] { Types.CHAR };
}

From source file:org.lexevs.dao.database.ibatis.sqlmap.NumericBooleanTypeHandler.java

public void setParameter(ParameterSetter setter, Object parameter) {
    if (parameter == null) {
        try {//from  www. j av  a 2  s  .c  o  m
            setter.setNull(Types.CHAR);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    } else {
        try {
            Boolean bool = (Boolean) parameter;
            if (bool) {
                setter.setString(TRUE);
            } else {
                setter.setString(FALSE);
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}

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

public ModifiedPathInserter(DataSource dataSource) {
    setDataSource(dataSource);//from  www. ja v a 2s  .  c  o m
    setSql("insert into modified_paths " + "(build_id, change_set_id, modified_path, modification_type) "
            + "values (?, ?, ?, ?)");

    declareParameter(new SqlParameter(Types.NUMERIC));
    declareParameter(new SqlParameter(Types.NUMERIC));
    declareParameter(new SqlParameter(Types.VARCHAR));
    declareParameter(new SqlParameter(Types.CHAR));

    compile();
}

From source file:org.apache.ojb.broker.metadata.FieldTypeClasses.java

/**
 * Returns a {@link FieldType} instance for the given sql type
 * (see {@link java.sql.Types}) as specified in JDBC 3.0 specification
 * (see JDBC 3.0 specification <em>Appendix B, Data Type Conversion Tables</em>).
 *
 * @param jdbcType Specify the type to look for.
 * @return A new specific {@link FieldType} instance.
 *//*from   w ww .  j a v a  2  s  .  c  om*/
static FieldType newFieldType(JdbcType jdbcType) {
    FieldType result = null;
    switch (jdbcType.getType()) {
    case Types.ARRAY:
        result = new ArrayFieldType();
        break;
    case Types.BIGINT:
        result = new LongFieldType();
        break;
    case Types.BINARY:
        result = new ByteArrayFieldType();
        break;
    case Types.BIT:
        result = new BooleanFieldType();
        break;
    case Types.BLOB:
        result = new BlobFieldType();
        break;
    case Types.CHAR:
        result = new StringFieldType();
        break;
    case Types.CLOB:
        result = new ClobFieldType();
        break;
    case Types.DATE:
        result = new DateFieldType();
        break;
    case Types.DECIMAL:
        result = new BigDecimalFieldType();
        break;
    // Not needed, user have to use the underlying sql datatype in OJB mapping files
    //            case Types.DISTINCT:
    //                result = new DistinctFieldType();
    //                break;
    case Types.DOUBLE:
        result = new DoubleFieldType();
        break;
    case Types.FLOAT:
        result = new FloatFieldType();
        break;
    case Types.INTEGER:
        result = new IntegerFieldType();
        break;
    case Types.JAVA_OBJECT:
        result = new JavaObjectFieldType();
        break;
    case Types.LONGVARBINARY:
        result = new ByteArrayFieldType();
        break;
    case Types.LONGVARCHAR:
        result = new StringFieldType();
        break;
    case Types.NUMERIC:
        result = new BigDecimalFieldType();
        break;
    case Types.REAL:
        result = new FloatFieldType();
        break;
    case Types.REF:
        result = new RefFieldType();
        break;
    case Types.SMALLINT:
        result = new ShortFieldType();
        break;
    case Types.STRUCT:
        result = new StructFieldType();
        break;
    case Types.TIME:
        result = new TimeFieldType();
        break;
    case Types.TIMESTAMP:
        result = new TimestampFieldType();
        break;
    case Types.TINYINT:
        result = new ByteFieldType();
        break;
    case Types.VARBINARY:
        result = new ByteArrayFieldType();
        break;
    case Types.VARCHAR:
        result = new StringFieldType();
        break;
    case Types.OTHER:
        result = new JavaObjectFieldType();
        break;
    //
    //            case Types.NULL:
    //                result = new NullFieldType();
    //                break;

    //#ifdef JDBC30
    case Types.BOOLEAN:
        result = new BooleanFieldType();
        break;
    case Types.DATALINK:
        result = new URLFieldType();
        break;
    //#endif
    default:
        throw new OJBRuntimeException("Unkown or not supported field type specified, specified jdbc type was '"
                + jdbcType + "', as string: " + JdbcTypesHelper.getSqlTypeAsString(jdbcType.getType()));
    }
    // make sure that the sql type was set
    result.setSqlType(jdbcType);
    return result;
}

From source file:org.gbif.drupal.mybatis.EnumDictTypeHandler.java

@Override
public void setParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {
    ps.setObject(i, parameter == null ? null : parameter.name(), Types.CHAR);
}

From source file:com.squid.core.jdbc.vendor.redshift.postgresql.PostgresqlJDBCDataFormatter.java

@Override
public Object unboxJDBCObject(final Object column, final int colType) throws SQLException {
    if (colType == Types.CHAR && column != null) {
        return StringUtils.stripEnd((String) column, " ");
    }// ww  w . jav a  2s.  c om
    return column;
}

From source file:com.squid.core.jdbc.vendor.greenplum.postgresql.PostgresqlJDBCDataFormatter.java

@Override
public Object unboxJDBCObject(final Object column, final int colType) throws SQLException {
    if (colType == Types.CHAR && column != null) {
        return StringUtils.stripEnd((String) column, " ");
    } else if (column instanceof PGInterval) {
        return column.toString();
    } else if (column instanceof PGobject) {
        return column.toString();
        //} else if (column instanceof java.sql.Date) {
        //   return new Date(((java.sql.Date)column).getTime());
    }//from   ww  w. ja va 2s .  c  o  m
    return column;
}

From source file:org.apache.openjpa.jdbc.schema.Schemas.java

/**
 * Return the SQL type name for the given {@link Types} constant.
 *///from w ww . jav  a 2  s  . c o m
public static String getJDBCName(int type) {
    switch (type) {
    case Types.ARRAY:
        return "array";
    case Types.BIGINT:
        return "bigint";
    case Types.BINARY:
        return "binary";
    case Types.BIT:
        return "bit";
    case Types.BLOB:
        return "blob";
    case Types.CHAR:
        return "char";
    case Types.CLOB:
        return "clob";
    case Types.DATE:
        return "date";
    case Types.DECIMAL:
        return "decimal";
    case Types.DISTINCT:
        return "distinct";
    case Types.DOUBLE:
        return "double";
    case Types.FLOAT:
        return "float";
    case Types.INTEGER:
        return "integer";
    case Types.JAVA_OBJECT:
        return "java_object";
    case Types.LONGVARBINARY:
        return "longvarbinary";
    case Types.LONGVARCHAR:
        return "longvarchar";
    case Types.NULL:
        return "null";
    case Types.NUMERIC:
        return "numeric";
    case Types.OTHER:
        return "other";
    case Types.REAL:
        return "real";
    case Types.REF:
        return "ref";
    case Types.SMALLINT:
        return "smallint";
    case Types.STRUCT:
        return "struct";
    case Types.TIME:
        return "time";
    case Types.TIMESTAMP:
        return "timestamp";
    case Types.TINYINT:
        return "tinyint";
    case Types.VARBINARY:
        return "varbinary";
    case Types.VARCHAR:
        return "varchar";
    default:
        return "unknown(" + type + ")";
    }
}

From source file:net.sf.jdbcwrappers.trim.TrimmingResultSetWrapper.java

private void fetchCharColumns() throws SQLException {
    if (charColumns == null) {
        ResultSetMetaData metadata = getMetaData();
        int columnCount = metadata.getColumnCount();
        charColumns = new HashSet<String>();
        isCharColumn = new boolean[columnCount];
        for (int i = 1; i <= columnCount; i++) {
            if (metadata.getColumnType(i) == Types.CHAR) {
                charColumns.add(metadata.getColumnName(i).toUpperCase());
                isCharColumn[i - 1] = true;
            }// w w w.  j  a v  a2s. c o  m
        }
        if (log.isDebugEnabled()) {
            log.debug("CHAR columns: " + charColumns);
        }
    }
}