Example usage for java.sql Types DATE

List of usage examples for java.sql Types DATE

Introduction

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

Prototype

int DATE

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

Click Source Link

Document

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

Usage

From source file:orz.neptune.prospring3.ch8.UpdateContact.java

public UpdateContact(DataSource dataSource) {
    super(dataSource, SQL_UPDATE_CONTACT);
    super.declareParameter(new SqlParameter("first_name", Types.VARCHAR));
    super.declareParameter(new SqlParameter("last_name", Types.VARCHAR));
    super.declareParameter(new SqlParameter("birth_date", Types.DATE));
    super.declareParameter(new SqlParameter("id", Types.INTEGER));
}

From source file:orz.neptune.prospring3.ch8.InsertContact.java

public InsertContact(DataSource dataSource) {
    super(dataSource, SQL_INSERT_CONTACT);
    super.declareParameter(new SqlParameter("first_name", Types.VARCHAR));
    super.declareParameter(new SqlParameter("last_name", Types.VARCHAR));
    super.declareParameter(new SqlParameter("birth_date", Types.DATE));
    super.setGeneratedKeysColumnNames(new String[] { "id" });
    super.setReturnGeneratedKeys(true);
}

From source file:com.home.ln_spring.ch8.dao.jdbc.annotation.InsertContact.java

public InsertContact(DataSource dataSource) {
    super(dataSource, SQL_INSERT_CONTACT);
    super.declareParameter(new SqlParameter("first_name", Types.VARCHAR));
    super.declareParameter(new SqlParameter("last_name", Types.VARCHAR));
    super.declareParameter(new SqlParameter("birth_date", Types.DATE));
    super.setGeneratedKeysColumnNames(new String[] { "contact_id" });
    super.setReturnGeneratedKeys(true);
}

From source file:com.home.ln_spring.ch8.dao.jdbc.annotation.UpdateContact.java

public UpdateContact(DataSource dataSource) {
    super(dataSource, SQL_UPDATE_CONTACT);
    super.declareParameter(new SqlParameter("first_name", Types.VARCHAR));
    super.declareParameter(new SqlParameter("last_name", Types.VARCHAR));
    super.declareParameter(new SqlParameter("birth_date", Types.DATE));
    super.declareParameter(new SqlParameter("contact_id", Types.INTEGER));
}

From source file:FacturaDAO.java

@Override
public void alta(Factura f) {
    String inserQuery = "insert into TFacturas (idFactura, idCliente, Fecha, Importe) values (?, ?, ?, ?) ";
    Object[] params = new Object[] { f.getIdFactura(), f.getIdCliente(), f.getFecha(), f.getImporte() };
    int[] types = new int[] { Types.INTEGER, Types.INTEGER, Types.DATE, Types.DECIMAL };
    jdbcTemplate.update(inserQuery, params, types);
}

From source file:org.apache.hadoop.hive.ql.dataImport.HiveTypes.java

public static boolean isHiveTypeImprovised(int sqlType) {
    return sqlType == Types.DATE || sqlType == Types.TIME || sqlType == Types.TIMESTAMP
            || sqlType == Types.DECIMAL || sqlType == Types.NUMERIC;
}

From source file:com.mirth.connect.donkey.model.channel.MetaDataColumnType.java

public static MetaDataColumnType fromSqlType(int sqlType) {
    switch (sqlType) {
    case Types.VARCHAR:
    case Types.NVARCHAR:
    case Types.LONGVARCHAR:
    case Types.LONGNVARCHAR:
    case Types.CLOB:
    case Types.NCLOB:
        return STRING;

    case Types.BIGINT:
    case Types.INTEGER:
    case Types.SMALLINT:
    case Types.TINYINT:
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.NUMERIC:
    case Types.REAL:
        return NUMBER;

    case Types.BOOLEAN:
    case Types.BIT:
    case Types.CHAR:
        return BOOLEAN;

    case Types.TIMESTAMP:
    case Types.TIME:
    case Types.DATE:
        return TIMESTAMP;
    }/*  ww w.  j a va  2 s  .  c  o m*/

    return null;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.misc.tablemodel.TypeMapper.java

private static Class mapSQLType(final int t) {
    switch (t) {/* w w w  .  j a v a2s .com*/
    case Types.ARRAY:
        return Object[].class;
    case Types.BIGINT:
        return Long.class;
    case Types.BINARY:
        return byteArrayClass;
    case Types.BIT:
        return Boolean.class;
    case Types.BLOB:
        return Blob.class;
    case Types.BOOLEAN: // Types.BOOLEAN was not part of JDK1.2.2
        return Boolean.class;
    case Types.CHAR:
        return String.class;
    case Types.CLOB:
        return Clob.class;
    case Types.DATALINK: // Types.DATALINK was not part of JDK 1.2.2
        return URL.class;
    case Types.DATE:
        return java.sql.Date.class;
    case Types.DECIMAL:
        return java.math.BigDecimal.class;
    case Types.DISTINCT:
        return Object.class;
    case Types.DOUBLE:
        return Double.class;
    case Types.FLOAT:
        return Double.class;
    case Types.INTEGER:
        return Integer.class;
    case Types.JAVA_OBJECT:
        return Object.class;
    case Types.LONGVARBINARY:
        return byteArrayClass;
    case Types.LONGVARCHAR:
        return String.class;
    case Types.NCLOB:
        return NClob.class;
    case Types.NULL:
        return Object.class;
    case Types.NUMERIC:
        return java.math.BigDecimal.class;
    case Types.NCHAR:
    case Types.NVARCHAR:
    case Types.LONGNVARCHAR:
        return String.class;
    case Types.OTHER:
        return Object.class;
    case Types.REAL:
        return Float.class;
    case Types.REF:
        return Ref.class;
    case Types.ROWID:
        return RowId.class;
    case Types.SMALLINT:
        return Short.class;
    case Types.STRUCT:
        return Struct.class;
    case Types.SQLXML:
        return SQLXML.class;
    case Types.TIME:
        return Time.class;
    case Types.TIMESTAMP:
        return Timestamp.class;
    case Types.TINYINT:
        return Byte.class;
    case Types.VARBINARY:
        return byteArrayClass;
    case Types.VARCHAR:
        return String.class;
    default:
        return Object.class;
    }
}

From source file:solidbase.core.plugins.DBReader.java

public DBReader(ResultSet result, ExportLogger counter, boolean dateAsTimestamp) throws SQLException {
    this.result = result;
    this.counter = counter;

    ResultSetMetaData metaData = result.getMetaData();
    int count = metaData.getColumnCount();
    this.columns = new Column[count];

    for (int i = 0; i < count; i++) {
        int col = i + 1;
        String name = metaData.getColumnName(col).toUpperCase();
        int type = metaData.getColumnType(col);
        if (type == Types.DATE && dateAsTimestamp)
            type = Types.TIMESTAMP;
        String table = StringUtils.upperCase(StringUtils.defaultIfEmpty(metaData.getTableName(col), null));
        String schema = StringUtils.upperCase(StringUtils.defaultIfEmpty(metaData.getSchemaName(col), null));
        this.columns[i] = new Column(name, type, table, schema);
    }/* w  w  w  . ja va  2s . c  om*/
}

From source file:com.cloudera.sqoop.hive.HiveTypes.java

/**
 * Given JDBC SQL types coming from another database, what is the best
 * mapping to a Hive-specific type?//from  w ww.  jav a2s. c o  m
 */
public static String toHiveType(int sqlType) {
    if (sqlType == Types.INTEGER) {
        return "INT";
    } else if (sqlType == Types.VARCHAR) {
        return "STRING";
    } else if (sqlType == Types.CHAR) {
        return "STRING";
    } else if (sqlType == Types.LONGVARCHAR) {
        return "STRING";
    } else if (sqlType == Types.NUMERIC) {
        // Per suggestion on hive-user, this is converted to DOUBLE for now.
        return "DOUBLE";
    } else if (sqlType == Types.DECIMAL) {
        // Per suggestion on hive-user, this is converted to DOUBLE for now.
        return "DOUBLE";
    } else if (sqlType == Types.BIT) {
        return "BOOLEAN";
    } else if (sqlType == Types.BOOLEAN) {
        return "BOOLEAN";
    } else if (sqlType == Types.TINYINT) {
        return "TINYINT";
    } else if (sqlType == Types.SMALLINT) {
        return "INT";
    } else if (sqlType == Types.BIGINT) {
        return "BIGINT";
    } else if (sqlType == Types.REAL) {
        return "DOUBLE";
    } else if (sqlType == Types.FLOAT) {
        return "DOUBLE";
    } else if (sqlType == Types.DOUBLE) {
        return "DOUBLE";
    } else if (sqlType == Types.DATE) {
        // unfortunate type coercion
        return "STRING";
    } else if (sqlType == Types.TIME) {
        // unfortunate type coercion
        return "STRING";
    } else if (sqlType == Types.TIMESTAMP) {
        // unfortunate type coercion
        return "STRING";
    } else if (sqlType == Types.CLOB) {
        return "STRING";
    } else {
        // TODO(aaron): Support BINARY, VARBINARY, LONGVARBINARY, DISTINCT,
        // BLOB, ARRAY, STRUCT, REF, JAVA_OBJECT.
        return null;
    }
}