List of usage examples for java.sql Types VARCHAR
int VARCHAR
To view the source code for java.sql Types VARCHAR.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type VARCHAR
.
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 },/*w w 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 .j a va 2 s. c o m*/ */ 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:db.migration.V055__UpdateECTS.java
public void migrate(JdbcTemplate jdbcTemplate) throws Exception { LOG.info("migrate()..."); // Get all organisaatiometadatas where there are strings to process List<Map> resultSet = jdbcTemplate.query( "SELECT id,hakutoimistoectsemail,hakutoimistoectsnimi,hakutoimistoectspuhelin,hakutoimistoectstehtavanimike FROM organisaatiometadata WHERE hakutoimistoectsemail<>'' OR hakutoimistoectsnimi<>'' OR hakutoimistoectspuhelin<>'' OR hakutoimistoectstehtavanimike<>''", new RowMapper<Map>() { @Override//from w w w .j a v a2 s . c om public Map mapRow(ResultSet rs, int rowNum) throws SQLException { Map r = new HashMap<String, Object>(); ResultSetMetaData metadata = rs.getMetaData(); for (int i = 1; i <= metadata.getColumnCount(); i++) { String cname = metadata.getColumnName(i); int ctype = metadata.getColumnType(i); switch (ctype) { case Types.VARCHAR: // hakutoimistoectsemail,hakutoimistoectsnimi,hakutoimistoectspuhelin,hakutoimistoectstehtavanimike r.put(cname, rs.getString(cname)); break; case Types.BIGINT: // id r.put(cname, rs.getInt(cname)); break; default: break; } } LOG.debug(" read from db : organisaatiometadata = {}", r); return r; } }); // Move strings to monikielinenteksti_values for (Map orgmd : resultSet) { handleOrganisaatiometadata(orgmd, jdbcTemplate); } LOG.info("migrate()... done."); }
From source file:au.com.ish.derbydump.derbydump.metadata.Column.java
/** * Get a string value for the value in this column in the datarow * /*w ww.ja v a2 s . c om*/ * @param dataRow The row which we are exporting * @return an SQL statement compliant string version of the value */ public String toString(ResultSet dataRow) throws SQLException { switch (getColumnDataType()) { case Types.BINARY: case Types.VARBINARY: case Types.BLOB: { Blob obj = dataRow.getBlob(columnName); return (obj == null) ? "NULL" : processBinaryData(obj); } case Types.CLOB: { Clob obj = dataRow.getClob(columnName); return (obj == null) ? "NULL" : processClobData(obj); } case Types.CHAR: case Types.LONGNVARCHAR: case Types.VARCHAR: { String obj = dataRow.getString(columnName); return (obj == null) ? "NULL" : processStringData(obj); } case Types.TIME: { Time obj = dataRow.getTime(columnName); return (obj == null) ? "NULL" : processStringData(obj.toString()); } case Types.DATE: { Date obj = dataRow.getDate(columnName); return (obj == null) ? "NULL" : processStringData(obj.toString()); } case Types.TIMESTAMP: { Timestamp obj = dataRow.getTimestamp(columnName); return (obj == null) ? "NULL" : processStringData(obj.toString()); } case Types.SMALLINT: { Object obj = dataRow.getObject(columnName); return (obj == null) ? "NULL" : obj.toString(); } case Types.BIGINT: { Object obj = dataRow.getObject(columnName); return (obj == null) ? "NULL" : obj.toString(); } case Types.INTEGER: { Object obj = dataRow.getObject(columnName); return (obj == null) ? "NULL" : obj.toString(); } case Types.NUMERIC: case Types.DECIMAL: { BigDecimal obj = dataRow.getBigDecimal(columnName); return (obj == null) ? "NULL" : String.valueOf(obj); } case Types.REAL: case Types.FLOAT: { Float obj = dataRow.getFloat(columnName); // dataRow.getFloat() always returns a value. only way to check the null is wasNull() method return (dataRow.wasNull()) ? "NULL" : String.valueOf(obj); } case Types.DOUBLE: { Double obj = dataRow.getDouble(columnName); return (dataRow.wasNull()) ? "NULL" : String.valueOf(obj); } default: { Object obj = dataRow.getObject(columnName); return (obj == null) ? "NULL" : obj.toString(); } } }
From source file:ar.com.zauber.commons.gis.spots.impl.SQLGeonameSpotDAO.java
/** @see GeonameSpotDAO#getSpotsIn(Polygon) */ public final Collection<GeonameSpot> getSpotsIn(final Polygon polygon) { final String sql = SELECT_WHAT + " WHERE the_geom && " + "GeometryFromText(?, 4326);"; return (Collection<GeonameSpot>) jdbcTemplate.query(sql, new Object[] { writer.write(polygon) }, new int[] { Types.VARCHAR }, new GeonameSpotExtractor(wktReader)); }
From source file:com.adaptris.core.services.jdbc.types.StringColumnTranslatorTest.java
@Test public void testStringTranslator() throws Exception { JdbcResultRow row = new JdbcResultRow(); row.setFieldValue("testField", "111", Types.VARCHAR); {//from w w w.j ava 2 s . c o m String translated = translator.translate(row, 0); assertEquals("111", translated); } { String translated = translator.translate(row, "testField"); assertEquals("111", translated); } }
From source file:dk.teachus.backend.dao.hibernate.PasswordUserType.java
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { if (value != null) { if (value instanceof String == false) { throw new HibernateException("Value must be instance of string"); }/*from w w w . ja v a 2 s .c o m*/ String stringValue = (String) value; // Encrypt the value with sha1 try { // Bad way of figuring out if we should encrypt or not. // Please think of something smarter, but for now I guess it's ok Matcher matcher = SHA1_PATTERN.matcher(stringValue); if (matcher.matches()) { st.setString(index, stringValue); } else { String sha1Value = sha1(stringValue); st.setString(index, sha1Value); } } catch (NoSuchAlgorithmException e) { throw new HibernateException(e); } catch (UnsupportedEncodingException e) { throw new HibernateException(e); } } else { st.setNull(index, Types.VARCHAR); } }
From source file:org.sakaiproject.imagegallery.service.impl.ImageGalleryServiceImpl.java
public void init() { super.init(); insertImage = new PreparedStatementCreatorFactory( "insert into IMAGE_GALLERY_IMAGE_T (CONTEXT, TITLE, DESCRIPTION, FILE_ID) values (?, ?, ?, ?)", new int[] { Types.VARCHAR, Types.VARCHAR, Types.LONGVARCHAR, Types.VARCHAR }); }
From source file:cn.guoyukun.spring.jpa.repository.hibernate.type.ObjectSerializeUserType.java
/** * Hibernate??/* w w w.j a va 2 s. c o m*/ * ?PreparedStateme?? */ @Override public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { ObjectOutputStream oos = null; if (value == null) { st.setNull(index, Types.VARCHAR); } else { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); oos.writeObject(value); oos.close(); byte[] objectBytes = bos.toByteArray(); String hexStr = Hex.encodeHexString(objectBytes); st.setString(index, hexStr); } catch (Exception e) { throw new HibernateException(e); } finally { try { oos.close(); } catch (IOException e) { } } } }
From source file:com.redsqirl.workflow.utils.jdbc.GenericConfFile.java
public GenericConfFile(String name, Connection conn) throws SQLException { dictionaryName = name;//from w w w .ja v a 2 s .co m databaseMetaData = conn.getMetaData(); typeRecognized = new LinkedHashMap<Integer, FieldType>(); typeRecognized.put(Types.BOOLEAN, FieldType.BOOLEAN); typeRecognized.put(Types.DATE, FieldType.DATETIME); typeRecognized.put(Types.TIME, FieldType.DATETIME); typeRecognized.put(Types.DOUBLE, FieldType.DOUBLE); typeRecognized.put(Types.NUMERIC, FieldType.DOUBLE); typeRecognized.put(Types.DECIMAL, FieldType.DOUBLE); typeRecognized.put(Types.REAL, FieldType.DOUBLE); typeRecognized.put(Types.FLOAT, FieldType.FLOAT); typeRecognized.put(Types.INTEGER, FieldType.INT); typeRecognized.put(Types.SMALLINT, FieldType.INT); typeRecognized.put(Types.TINYINT, FieldType.INT); typeRecognized.put(Types.BIGINT, FieldType.LONG); typeRecognized.put(Types.VARCHAR, FieldType.STRING); typeRecognized.put(Types.CHAR, FieldType.STRING); typeRecognized.put(Types.LONGVARCHAR, FieldType.STRING); typeRecognized.put(Types.NVARCHAR, FieldType.STRING); typeRecognized.put(Types.NCHAR, FieldType.STRING); typeRecognized.put(Types.LONGNVARCHAR, FieldType.STRING); typeRecognized.put(Types.TIMESTAMP, FieldType.TIMESTAMP); }