List of usage examples for java.sql Types TIMESTAMP
int TIMESTAMP
To view the source code for java.sql Types TIMESTAMP.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TIMESTAMP
.
From source file:net.sourceforge.vulcan.spring.jdbc.ChangeSetInserter.java
public ChangeSetInserter(DataSource dataSource) { setDataSource(dataSource);//ww w. ja v a 2 s . co m setSql("insert into change_sets " + "(build_id, change_set_id, message, revision_label, commit_timestamp, author, author_email) " + "values (?, ?, ?, ?, ?, ?, ?)"); declareParameter(new SqlParameter(Types.NUMERIC)); declareParameter(new SqlParameter(Types.NUMERIC)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.TIMESTAMP)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); compile(); modifiedPathInserter = new ModifiedPathInserter(dataSource); }
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?/* w w w. j a va2 s . com*/ */ 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; } }
From source file:com.nabla.wapp.server.json.SqlColumn.java
public SqlColumn(String label, int type, int length) { this.label = label; this.type = (type == Types.TINYINT) ? (length == 1 ? Types.BOOLEAN : type) : type; if (log.isDebugEnabled()) { String s;/*from w ww. j a va 2s. c o m*/ switch (this.type) { case Types.BIGINT: case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: s = "INTEGER"; break; case Types.BOOLEAN: case Types.BIT: s = "BOOLEAN"; break; case Types.DATE: s = "DATE"; break; case Types.TIMESTAMP: s = "TIMESTAMP"; break; case Types.DOUBLE: s = "DOUBLE"; break; case Types.FLOAT: s = "FLOAT"; break; case Types.NULL: s = "NULL"; break; default: s = "STRING"; break; } log.debug("column '" + this.label + "' " + s); } }
From source file:org.apache.ddlutils.platform.DefaultValueHelper.java
/** * Converts the given default value from the specified original to the target * jdbc type.//from ww w . j a v a2 s . c o m * * @param defaultValue The default value * @param originalTypeCode The original type code * @param targetTypeCode The target type code * @return The converted default value */ public String convert(String defaultValue, int originalTypeCode, int targetTypeCode) { String result = defaultValue; if (defaultValue != null) { switch (originalTypeCode) { case Types.BIT: case Types.BOOLEAN: result = convertBoolean(defaultValue, targetTypeCode).toString(); break; case Types.DATE: if (targetTypeCode == Types.TIMESTAMP) { try { Date date = Date.valueOf(result); return new Timestamp(date.getTime()).toString(); } catch (IllegalArgumentException ex) { } } break; case Types.TIME: if (targetTypeCode == Types.TIMESTAMP) { try { Time time = Time.valueOf(result); return new Timestamp(time.getTime()).toString(); } catch (IllegalArgumentException ex) { } } break; } } return result; }
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:com.espertech.esper.util.TestSQLTypeMapUtil.java
public void testMapping() { Map<Integer, Class> testData = new HashMap<Integer, Class>(); testData.put(Types.CHAR, String.class); testData.put(Types.VARCHAR, String.class); testData.put(Types.LONGVARCHAR, String.class); testData.put(Types.NUMERIC, BigDecimal.class); testData.put(Types.DECIMAL, BigDecimal.class); testData.put(Types.BIT, Boolean.class); testData.put(Types.BOOLEAN, Boolean.class); testData.put(Types.TINYINT, Byte.class); testData.put(Types.SMALLINT, Short.class); testData.put(Types.INTEGER, Integer.class); testData.put(Types.BIGINT, Long.class); testData.put(Types.REAL, Float.class); testData.put(Types.FLOAT, Double.class); testData.put(Types.DOUBLE, Double.class); testData.put(Types.BINARY, byte[].class); testData.put(Types.VARBINARY, byte[].class); testData.put(Types.LONGVARBINARY, byte[].class); testData.put(Types.DATE, java.sql.Date.class); testData.put(Types.TIMESTAMP, java.sql.Timestamp.class); testData.put(Types.TIME, java.sql.Time.class); testData.put(Types.CLOB, java.sql.Clob.class); testData.put(Types.BLOB, java.sql.Blob.class); testData.put(Types.ARRAY, java.sql.Array.class); testData.put(Types.STRUCT, java.sql.Struct.class); testData.put(Types.REF, java.sql.Ref.class); testData.put(Types.DATALINK, java.net.URL.class); for (int type : testData.keySet()) { Class result = SQLTypeMapUtil.sqlTypeToClass(type, null); log.debug(".testMapping Mapping " + type + " to " + result.getSimpleName()); assertEquals(testData.get(type), result); }/*from w w w . ja va2 s .com*/ assertEquals(String.class, SQLTypeMapUtil.sqlTypeToClass(Types.JAVA_OBJECT, "java.lang.String")); assertEquals(String.class, SQLTypeMapUtil.sqlTypeToClass(Types.DISTINCT, "java.lang.String")); }
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 w w w . ja va2 s.c om }
From source file:konditer_reorganized_database.dao.OrdereDao.java
@Override public void addOrdere(int orderId, int customerId, int orderStatusId, int deliveryId, Date orderDateIncome, Date orderDateEnd, double orderCakePrice, double orderDeliveryPrice, String orderInsidesId, String orderInfo) {//from www . ja v a2 s . com String SQL_QUERY = "INSERT INTO orders ( ORDER_ID, " + "CUSTOMER_ID, " + "ORDER_STATUS_ID, " + "DELIVERY_ID, " + "ORDER_DATE_INCOME, " + "ORDER_DATE_END, " + "ORDER_CAKE_PRICE, " + "ORDER_DELIVERY_PRICE, " + "ORDER_INSIDES_ID, " + "ORDER_INFO ) " + "VALUES (?,?,?,?,?,?,?,?,?,?)"; int rowCount = jdbcTemplate.update(SQL_QUERY, new Object[] { orderId, customerId, orderStatusId, deliveryId, orderDateIncome, orderDateEnd, orderCakePrice, orderDeliveryPrice, orderInsidesId, orderInfo }, new int[] { Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP, Types.DOUBLE, Types.DOUBLE, Types.VARCHAR, Types.VARCHAR }); Logger.getLogger(CakeDao.class.getName()).log(Level.SEVERE, " : {0} .", rowCount); System.out.println(ordereDao.getOrdere(orderId).toString()); }
From source file:com.tesora.dve.db.mysql.MysqlNativeResultHandler.java
@Override protected byte[] getDateAsBytes(ColumnMetadata uc, Object obj) { if (uc.getDataType() == Types.TIME) return getTimeAsBytes(uc, new Time(((Date) obj).getTime())); if (uc.getDataType() == Types.TIMESTAMP) return getTimestampAsBytes(uc, new Timestamp(((Date) obj).getTime())); if (((Date) obj).equals(ZERO_DATE_INDICATOR)) return ZERO_DATE.getBytes(); return dateFormatter.format((Date) obj).getBytes(); }
From source file:konditer.client.dao.CustomerDao.java
@Override public void addCustomer(int customerId, int discountId, String customerLastName, String customerFirstName, String customerParentName, Date customerDateBorn, String customerInfo) { String SQL_QUERY = "INSERT INTO customers ( CUSTOMER_ID, " + "DISCOUNT_ID, " + "CUSTOMER_LAST_NAME, " + "CUSTOMER_FIRST_NAME, " + "CUSTOMER_PARENT_NAME, " + "CUSTOMER_DATE_BORN, " + "CUSTOMER_INFO ) " + "VALUES (?,?,?,?,?,?,?)"; int rowCount = 0; try {// w w w.j av a 2 s. c o m rowCount = jdbcTemplate.update(SQL_QUERY, new Object[] { customerId, discountId, customerLastName, customerFirstName, customerParentName, customerDateBorn, customerInfo }, new int[] { Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR }); Logger.getLogger(CustomerDao.class.getName()).log(Level.SEVERE, " : {0} .", rowCount); System.out.println(customerDao.getCustomer(customerId).toString()); } catch (DataAccessException e) { rowCount = 0; Logger.getLogger(CustomerDao.class.getName()).log(Level.SEVERE, " . ?: {0} .", rowCount); } }