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:com.egeniuss.appmarket.controller.AppManagerController.java
@RequestMapping("/listApp.html") public @ResponseBody List<Map<String, Object>> listApp(HttpServletRequest request) { StringBuilder sql = new StringBuilder( "select am.*, ak.APP_NAME, ar.RELEASE_NAME from APP_MARKET am, APP_KEY_MAPPING ak, APP_RELEASE_MAPPING ar where am.APP_KEY = ak.APP_KEY and am.APP_ENV = ar.RELEASE_KEY"); List<Object> params = new ArrayList<Object>(); List<Integer> types = new ArrayList<Integer>(); String appKey = request.getParameter("appKey"); if (appKey != null && !"".equals(appKey)) { sql.append(" and am.APP_KEY = ?"); params.add(appKey);//from ww w .java 2 s.c om types.add(Types.VARCHAR); } String appPlatform = request.getParameter("appPlatform"); if (appPlatform != null && !"".equals(appPlatform)) { sql.append(" and am.APP_PLATFORM = ?"); params.add(appPlatform); types.add(Types.VARCHAR); } String appEnv = request.getParameter("appEnv"); if (appEnv != null && !"".equals(appEnv)) { sql.append(" and am.APP_ENV = ?"); params.add(appEnv); types.add(Types.VARCHAR); } sql.append(" order by am.CREATE_TIME desc"); List<Map<String, Object>> list = null; if (params.size() == 0) { list = jdbcTemplate.queryForList(sql.toString()); } else { int[] sqlTypes = new int[types.size()]; for (int i = 0; i < types.size(); i++) { sqlTypes[i] = types.get(i); } list = jdbcTemplate.queryForList(sql.toString(), params.toArray(), sqlTypes); } return list; }
From source file:at.molindo.dbcopy.util.Utils.java
public static boolean isStringType(int dataType) { switch (dataType) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: case Types.NCHAR: case Types.NVARCHAR: case Types.LONGNVARCHAR: return true; default:/*from w w w . ja va2 s . c om*/ return false; } }
From source file:dao.DirBlobTitleQuery.java
/** * For each row in the result set, the mapRow method is called by * Spring. In the very first call to mapRow() for the first row in the result * set, we make a call to RSMD to get columnNames and cache * them to a local array in this object. This way, we can avoid multiple calls * to RSMD since, spring calls mapRow many times (one per row in result set). * */// w ww .ja v a 2 s . co m DirBlobTitleQuery(DataSource ds) { super(ds, "select 1 from dirblob where directoryid=? and btitle=?"); declareParameter(new SqlParameter("directoryid", Types.BIGINT)); declareParameter(new SqlParameter("btitle", Types.VARCHAR)); compile(); }
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 a va 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); } }
From source file:net.sourceforge.vulcan.spring.jdbc.HistoryQueryBuilder.java
static void buildQuery(String selectClause, BuildOutcomeQueryDto dto, BuilderQuery query) { final Set<String> projectNames = dto.getProjectNames(); if (projectNames == null || projectNames.isEmpty()) { throw new IllegalArgumentException("Must query for at least one project name"); }/* www . j a v a 2 s. com*/ final List<? super Object> params = new ArrayList<Object>(); final StringBuilder sb = new StringBuilder(); sb.append("where project_names.name"); query.declareParameter(new SqlParameter(Types.VARCHAR)); if (projectNames.size() == 1) { sb.append("=?"); params.addAll(projectNames); } else { sb.append(" in (?"); for (int i = 1; i < projectNames.size(); i++) { sb.append(",?"); query.declareParameter(new SqlParameter(Types.VARCHAR)); } sb.append(")"); final List<String> sorted = new ArrayList<String>(projectNames); Collections.sort(sorted); params.addAll(sorted); } if (dto.getMinDate() != null) { sb.append(" and completion_date>=?"); params.add(dto.getMinDate()); query.declareParameter(new SqlParameter(Types.TIMESTAMP)); } if (dto.getMaxDate() != null) { sb.append(" and completion_date<?"); params.add(dto.getMaxDate()); query.declareParameter(new SqlParameter(Types.TIMESTAMP)); } if (dto.getMinBuildNumber() != null) { sb.append(" and build_number>=?"); params.add(dto.getMinBuildNumber()); query.declareParameter(new SqlParameter(Types.INTEGER)); } if (dto.getMaxBuildNumber() != null) { sb.append(" and build_number<=?"); params.add(dto.getMaxBuildNumber()); query.declareParameter(new SqlParameter(Types.INTEGER)); } final Set<Status> statuses = dto.getStatuses(); if (statuses != null && !statuses.isEmpty()) { query.declareParameter(new SqlParameter(Types.VARCHAR)); sb.append(" and status in (?"); for (int i = 1; i < statuses.size(); i++) { query.declareParameter(new SqlParameter(Types.VARCHAR)); sb.append(",?"); } sb.append(")"); params.addAll(statuses); } if (dto.getUpdateType() != null) { query.declareParameter(new SqlParameter(Types.VARCHAR)); sb.append(" and update_type=?"); params.add(dto.getUpdateType().name()); } if (isNotBlank(dto.getRequestedBy())) { query.declareParameter(new SqlParameter(Types.VARCHAR)); sb.append(" and requested_by=?"); params.add(dto.getRequestedBy()); } query.setParameterValues(params.toArray()); query.setSql(selectClause + sb.toString()); }
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) {// w w w. j a va 2 s . c o m 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.adaptris.core.services.jdbc.types.StringColumnTranslatorTest.java
@Test public void testAsFloatTranslator() throws Exception { JdbcResultRow row = new JdbcResultRow(); row.setFieldValue("testField", new Float(111), Types.VARCHAR); {//from www . j ava 2 s . c o m String translated = translator.translate(row, 0); assertEquals("111.0", translated); } { String translated = translator.translate(row, "testField"); assertEquals("111.0", translated); } }
From source file:RowSetModel.java
public Class getColumnClass(int column) { String cname;//from ww w . ja v a 2 s.c o m 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.snaker.engine.spring.SpringJdbcAccess.java
public void saveProcess(final Process process) { super.saveProcess(process); if (process.getBytes() != null) { template.execute(PROCESS_UPDATE_BLOB, new AbstractLobCreatingPreparedStatementCallback(lobHandler) { protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException, DataAccessException { try { lobCreator.setBlobAsBytes(ps, 1, process.getBytes()); StatementCreatorUtils.setParameterValue(ps, 2, Types.VARCHAR, process.getId()); } catch (Exception e) { e.printStackTrace(); }//from w w w. j a va 2s .co m } }); } }
From source file:com.bluecollarcoder.dao.RecipeRepository.java
public void persist(final Recipe recipe) { KeyHolder key = new GeneratedKeyHolder(); jdbc.update((Connection con) -> { PreparedStatement stmt = con.prepareStatement( "insert into recipes (recipe_name, recipe_url, recipe_photo) values (?, ?, ?)", Statement.RETURN_GENERATED_KEYS); stmt.setString(1, recipe.getTitle()); stmt.setString(2, recipe.getUrl()); stmt.setString(3, recipe.getPhotoUrl()); return stmt; }, key);/*from www. j a v a2 s .c o m*/ Number recipeId = (Number) key.getKeys().get("recipe_id"); for (String name : recipe.getIngredients().keySet()) { key = new GeneratedKeyHolder(); jdbc.update((Connection con) -> { PreparedStatement stmt = con.prepareStatement( "insert into ingredients (ingredient_name) values (?)", Statement.RETURN_GENERATED_KEYS); stmt.setString(1, name); return stmt; }, key); Number ingredientId = (Number) key.getKeys().get("ingredient_id"); String amount = recipe.getIngredients().get(name); jdbc.update("insert into ingredient_amount (recipe_id, ingredient_id, amount) values (?, ?, ?)", new Object[] { recipeId, ingredientId, amount }, new int[] { Types.INTEGER, Types.INTEGER, Types.VARCHAR }); } }