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:co.nubetech.hiho.mapreduce.lib.db.apache.OracleDataDrivenDBInputFormat.java
/** * @return the DBSplitter implementation to use to divide the table/query into InputSplits. *///from www .j a v a 2 s . c o m @Override protected DBSplitter getSplitter(int sqlDataType) { switch (sqlDataType) { case Types.DATE: case Types.TIME: case Types.TIMESTAMP: return new OracleDateSplitter(); default: return super.getSplitter(sqlDataType); } }
From source file:konditer.client.dao.OrdereDao.java
@Override public void addOrdere(int orderId, int customerId, int orderStatusId, int deliveryId, Date orderDateIncome, Date orderDateEnd, double orderCakePrice, double orderDeliveryPrice, double orderWeight, String orderInsidesId, String orderInfo) { 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_WEIGHT, " + "ORDER_INSIDES_ID, " + "ORDER_INFO ) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?)"; int rowCount = jdbcTemplate.update(SQL_QUERY, new Object[] { orderId, customerId, orderStatusId, deliveryId, orderDateIncome, orderDateEnd, orderCakePrice, orderDeliveryPrice, orderWeight, orderInsidesId, orderInfo }, new int[] { Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP, Types.DOUBLE, Types.DOUBLE, Types.DOUBLE, Types.VARCHAR, Types.VARCHAR }); Logger.getLogger(CakeDao.class.getName()).log(Level.SEVERE, " : {0} .", rowCount);// w w w . ja va 2 s . c o m System.out.println(ordereDao.getOrdere(orderId).toString()); }
From source file:org.georepublic.db.utils.ResultSetConverter.java
public static JSONArray convert(ResultSet rs) throws SQLException, JSONException { JSONArray json = new JSONArray(); ResultSetMetaData rsmd = rs.getMetaData(); while (rs.next()) { int numColumns = rsmd.getColumnCount(); JSONObject obj = new JSONObject(); for (int i = 1; i < numColumns + 1; i++) { String column_name = rsmd.getColumnName(i); if (rsmd.getColumnType(i) == java.sql.Types.ARRAY) { obj.put(column_name, rs.getArray(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.BIGINT) { obj.put(column_name, rs.getInt(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.BOOLEAN) { obj.put(column_name, rs.getBoolean(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.BLOB) { obj.put(column_name, rs.getBlob(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.DOUBLE) { obj.put(column_name, rs.getDouble(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.FLOAT) { obj.put(column_name, rs.getFloat(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.INTEGER) { obj.put(column_name, rs.getInt(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.NVARCHAR) { obj.put(column_name, rs.getNString(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.VARCHAR) { obj.put(column_name, rs.getString(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.TINYINT) { obj.put(column_name, rs.getInt(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.SMALLINT) { obj.put(column_name, rs.getInt(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.DATE) { obj.put(column_name, rs.getDate(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.TIMESTAMP) { obj.put(column_name, rs.getTimestamp(column_name)); } else { obj.put(column_name, rs.getObject(column_name)); }/* ww w . j a va 2 s .c om*/ } json.put(obj); } return json; }
From source file:com.cloudera.sqoop.hive.HiveTypes.java
/** * @return true if a sql type can't be translated to a precise match * in Hive, and we have to cast it to something more generic. *//*from ww w . java 2 s .c o m*/ 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:org.kuali.kra.proposaldevelopment.dao.ojb.AttachmentDaoOjb.java
/** * // www . j a v a2 s. co m * @see org.kuali.kra.proposaldevelopment.dao.AttachmentDao#getPersonnelTimeStampAndUploadUser(java.lang.Integer, java.lang.String, java.lang.Integer) */ public Iterator getPersonnelTimeStampAndUploadUser(Integer proposalPersonNumber, String proposalNumber, Integer biographyNumber) { Criteria crit = new Criteria(); crit.addEqualTo("proposalPersonNumber", proposalPersonNumber); crit.addEqualTo("proposalNumber", proposalNumber); crit.addEqualTo("biographyNumber", biographyNumber); ReportQueryByCriteria q = QueryFactory.newReportQuery(ProposalPersonBiographyAttachment.class, crit); q.setAttributes(new String[] { "updateTimestamp", "updateUser" }); // it retrieved updateTimestamp as 'Date'. so has to set up the following. The repository looks fine. not sure why ? q.setJdbcTypes(new int[] { Types.TIMESTAMP, Types.VARCHAR }); return getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(q); }
From source file:com.streamsets.pipeline.lib.jdbc.multithread.TableReadContext.java
private static void setParamVal(PreparedStatement ps, int paramIdx, int sqlType, String paramVal) throws SQLException, StageException { Utils.checkState(OffsetQueryUtil.SQL_TYPE_TO_FIELD_TYPE.containsKey(sqlType), Utils.format("Unsupported Partition Offset Type: {}", sqlType)); //All Date/Time Types are stored as long offsets //Parse string to get long. switch (sqlType) { case Types.TIME: ps.setTime(paramIdx, new java.sql.Time(Long.valueOf(paramVal))); break;// ww w . j ava 2 s. co m case Types.DATE: ps.setDate(paramIdx, new java.sql.Date(Long.valueOf(paramVal))); break; case Types.TIMESTAMP: Timestamp ts = TableContextUtil.getTimestampForOffsetValue(paramVal); ps.setTimestamp(paramIdx, ts); break; default: ps.setObject(paramIdx, Field.create(OffsetQueryUtil.SQL_TYPE_TO_FIELD_TYPE.get(sqlType), paramVal).getValue()); } }
From source file:RowSetModel.java
public Class getColumnClass(int column) { String cname;//from w ww. j av a2s. com int type; try { ResultSetMetaData meta = rowSet.getMetaData(); if (meta == null) { return null; } type = meta.getColumnType(column + 1); } catch (SQLException e) { e.printStackTrace(); return super.getColumnClass(column); } switch (type) { case Types.BIT: { cname = "java.lang.Boolean"; break; } case Types.TINYINT: { cname = "java.lang.Byte"; break; } case Types.SMALLINT: { cname = "java.lang.Short"; break; } case Types.INTEGER: { cname = "java.lang.Integer"; break; } case Types.BIGINT: { cname = "java.lang.Long"; break; } case Types.FLOAT: case Types.REAL: { cname = "java.lang.Float"; break; } case Types.DOUBLE: { cname = "java.lang.Double"; break; } case Types.NUMERIC: { cname = "java.lang.Number"; break; } case Types.DECIMAL: { cname = "java.math.BigDecimal"; break; } case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: { cname = "java.lang.String"; break; } case Types.DATE: { cname = "java.sql.Date"; break; } case Types.TIME: { cname = "java.sql.Time"; break; } case Types.TIMESTAMP: { cname = "java.sql.Timestamp"; break; } case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: { cname = "byte[]"; break; } case Types.OTHER: case Types.JAVA_OBJECT: { cname = "java.lang.Object"; break; } case Types.CLOB: { cname = "java.sql.Clob"; break; } case Types.BLOB: { cname = "java.ssql.Blob"; break; } case Types.REF: { cname = "java.sql.Ref"; break; } case Types.STRUCT: { cname = "java.sql.Struct"; break; } default: { return super.getColumnClass(column); } } try { return Class.forName(cname); } catch (Exception e) { e.printStackTrace(); return super.getColumnClass(column); } }
From source file:org.jasig.cas.web.support.InspektrThrottledSubmissionByIpAddressAndUsernameHandlerInterceptorAdapter.java
@Override protected final int findCount(final HttpServletRequest request, final String usernameParameter, final int failureRangeInSeconds) { final String SQL = "Select count(*) from COM_AUDIT_TRAIL where AUD_CLIENT_IP = ? and AUD_USER = ? AND AUD_ACTION = ? AND APPLIC_CD = ? AND AUD_DATE >= ?"; final String userToUse = constructUsername(request, usernameParameter); final Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.SECOND, -1 * failureRangeInSeconds); final Date oldestDate = calendar.getTime(); return this.jdbcTemplate.queryForInt(SQL, new Object[] { request.getRemoteAddr(), userToUse, INSPEKTR_ACTION, this.applicationCode, oldestDate },// ww w. j av a2 s . c o m new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP }); }
From source file:com.surevine.chat.openfire.audit.dao.JdbcAuditDAO.java
/** * {@inheritDoc}.//from w w w . ja va 2 s. c om */ public void save(final AuditMessage auditMessage) { if (LOG.isDebugEnabled()) { LOG.debug("Saving audit message: " + auditMessage); } // Values being persisted Object[] args = { auditMessage.getEvent().toString(), auditMessage.getSender(), auditMessage.getReceiver(), new Timestamp(auditMessage.getEventTime().getTime()), auditMessage.getContent(), auditMessage.getSecurityLabel() }; // SQL types for the arguments being persisted int[] argTypes = { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR }; // Persist the audit message jdbcTemplate.update(INSERT, args, argTypes); }
From source file:com.thinkbiganalytics.discovery.util.ParserHelper.java
public static String sqlTypeToHiveType(Integer type) { switch (type) { case Types.BIGINT: return "bigint"; case Types.NUMERIC: case Types.DOUBLE: case Types.DECIMAL: return "double"; case Types.INTEGER: return "int"; case Types.FLOAT: return "float"; case Types.TINYINT: return "tinyint"; case Types.DATE: return "date"; case Types.TIMESTAMP: return "timestamp"; case Types.BOOLEAN: return "boolean"; case Types.BINARY: return "binary"; default://from ww w. j a v a 2s . c o m return "string"; } }