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:de.whs.poodle.repositories.CourseRepository.java
public void edit(Course course) { try {/*from w w w .j a v a 2 s . c o m*/ jdbc.update(con -> { CallableStatement cs = con.prepareCall("{ CALL update_course(?,?,?,?,?,?) }"); cs.setInt(1, course.getId()); cs.setString(2, course.getName()); cs.setBoolean(3, course.getVisible()); if (course.getPassword().trim().isEmpty()) cs.setNull(4, Types.VARCHAR); else cs.setString(4, course.getPassword()); Array otherInstructors = con.createArrayOf("int4", course.getOtherInstructorsIds().toArray()); cs.setArray(5, otherInstructors); Array linkedCourses = con.createArrayOf("int4", course.getLinkedCoursesIds().toArray()); cs.setArray(6, linkedCourses); return cs; }); } catch (DuplicateKeyException e) { throw new BadRequestException(); } }
From source file:konditer_reorganized_database.dao.CakeDao.java
@Override public void addCake(int cakeId, int customerId, double cakePrice, int orderId, String cakeName, double cakeWeight, String cakePhoto, String cakeKeywords, boolean cakeStatus) throws DataAccessException { String SQL_QUERY = "INSERT INTO cakes ( CAKE_ID, " + "CUSTOMER_ID, " + "CAKE_PRICE, " + "ORDER_ID, " + "CAKE_NAME, " + "CAKE_WEIGHT, " + "CAKE_PHOTO_MINI, " + "CAKE_PHOTO_MAXI, " + "CAKE_KEYWORDS, " + "CAKE_STATUS ) " + "VALUES (?,?,?,?,?,?,?,?,?,?)"; //int cakeId1 = genIdDao.getCakeId(); /*/*from www . ja v a 2s. co m*/ ??? ??? 2- ? ?? ? */ //try{ int rowCount = jdbcTemplate.update(SQL_QUERY, new Object[] { cakeId, customerId, cakePrice, orderId, cakeName, cakeWeight, "" + cakeId + "_s.jpg", "" + cakeId + ".jpg", cakeKeywords, cakeStatus }, new int[] { Types.INTEGER, Types.INTEGER, Types.DOUBLE, Types.INTEGER, Types.VARCHAR, Types.DOUBLE, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN }); Logger.getLogger(CakeDao.class.getName()).log(Level.SEVERE, " : {0} .", rowCount); //}catch(DataAccessException e){ // Logger.getLogger(CakeDao.class.getName()).log(Level.SEVERE, ". ."); //genIdDao.decrementCakeId(); //} }
From source file:com.mec.DAO.Passport.UserDAO.java
public List<GrantedAuthority> getUserRoles(Integer userID) { SimpleJdbcCall jdbcCall = new SimpleJdbcCall(ds).withCatalogName("SqlSp") .withProcedureName("paRolesGetByIdUsuario").withoutProcedureColumnMetaDataAccess() .declareParameters(new SqlParameter("idAplicacion", Types.INTEGER)) .declareParameters(new SqlParameter("idUsuario", Types.INTEGER)) .declareParameters(new SqlOutParameter("ErrText", Types.VARCHAR)) .returningResultSet("items", new MyRowMapper()); SqlParameterSource in = new MapSqlParameterSource().addValue("idAplicacion", 1).addValue("idUsuario", userID);//from ww w.j av a2s.co m return (List<GrantedAuthority>) jdbcCall.execute(in).entrySet().iterator().next().getValue(); }
From source file:com.hangum.tadpole.engine.sql.util.RDBTypeToJavaTypeUtils.java
/** * rdb type to java/*w w w .ja v a 2 s . c o m*/ * * @param rdbType * @return */ public static Integer getJavaType(String rdbType) { Integer javaType = mapTypes.get(rdbType); if (javaType == null) { // logger.info("SQL type to Java type not found is" + rdbType); return java.sql.Types.VARCHAR; } return javaType; }
From source file:ar.com.zauber.commons.gis.spots.impl.SQLGeonameSpotDAO.java
private long getCountSpotsWithNameLike(final String name) { final String sql = "SELECT COUNT(*) FROM geoname WHERE name ~* ?"; return jdbcTemplate.queryForLong(sql, new Object[] { name }, new int[] { Types.VARCHAR }); }
From source file:com.squid.core.jdbc.vendor.sqlserver.SQLServerJDBCDataFormatter.java
@Override public String formatJDBCObject(final Object column, final int colType) throws SQLException { if (column == null) { return ""; }/*from ww w . j a va 2 s . c o m*/ switch (colType) { case -9: //NVARCHAR case -15: //NCHAR case Types.BIT: return super.formatJDBCObject(this.unboxJDBCObject(column, colType), java.sql.Types.VARCHAR); } return super.formatJDBCObject(column, colType); }
From source file:org.voltdb.example.springjdbc.ContestantDao.java
public List<ContestantData> findContestant(String code) { MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue("code", new SqlParameterValue(Types.VARCHAR, code)); return query(selectSql, params, new ContestantRowMapper()); }
From source file:com.aw.core.dao.AWQueryExecuter.java
private <Rsl> List<Rsl> executeSQL(RowHandler<Rsl> rowHandler) { try {//from w w w . j a v a 2s .co m PreparedStatement stmt = connection.prepareStatement(sql); if (sqlParams != null) for (int i = 0; i < sqlParams.length; i++) { Object sqlParam = sqlParams[i]; if (sqlParam == null) stmt.setNull(i + 1, Types.VARCHAR); else stmt.setObject(i + 1, sqlParam); } List<Rsl> results = new ArrayList<Rsl>(AWQueryAbortable.DEF_LIST_SIZE); if (logger.isDebugEnabled()) logger.debug(DAOSql.buildSQL(sql, sqlParams)); ResultSet rs = stmt.executeQuery(); AWQueryAbortable queryAbortable = AWQueryAbortable.instance(); queryAbortable.resetRowCount(); while (rs.next()) { if (queryAbortable.isAborted()) break; Rsl rsl = rowHandler.handle(rs); results.add(rsl); queryAbortable.incRowCount(); } logger.debug("Results :" + results.size() + " abortedQuery:" + queryAbortable.isAborted()); rs.close(); stmt.close(); return results; } catch (Exception e) { logger.error("SQL:" + sql); throw AWBusinessException.wrapUnhandledException(logger, e); } }
From source file:io.lightlink.oracle.AbstractOracleType.java
protected ARRAY createArray(Connection con, Object value, String typeName) throws SQLException { if (value == null) return null; ArrayDescriptor arrayStructDesc = safeCreateArrayDescriptor(typeName, con); if (value == null) return null; if (value.getClass().isArray()) { value = Arrays.asList((Object[]) value); }/*from w ww . j a va 2 s.c o m*/ List records = (List) value; String baseName = arrayStructDesc.getBaseName(); int baseType = arrayStructDesc.getBaseType(); if (baseType == Types.VARCHAR || baseType == Types.CHAR || baseType == Types.CLOB || baseType == Types.NUMERIC || baseType == Types.INTEGER || baseType == Types.BIGINT || baseType == Types.FLOAT || baseType == Types.DOUBLE || baseType == Types.DECIMAL || baseType == Types.NCHAR || baseType == Types.NVARCHAR || baseType == Types.NCLOB) { return new ARRAY(arrayStructDesc, con, records.toArray()); // primitive array } else { Object[] structArray = new Object[records.size()]; for (int i = 0; i < structArray.length; i++) { Object record = records.get(i); if (baseType == OracleTypes.JAVA_STRUCT || baseType == OracleTypes.JAVA_OBJECT || baseType == OracleTypes.STRUCT || baseType == OracleTypes.JAVA_STRUCT) { record = createStruct(con, record, baseName); } else if (baseType == OracleTypes.ARRAY) { record = createArray(con, record, baseName); } structArray[i] = record; } return new ARRAY(arrayStructDesc, con, structArray); } }
From source file:kr.co.bitnine.octopus.testutils.MemoryDatabaseTest.java
private void verifyTableEquals(JSONObject expectedTable, ResultSet actualRows) throws Exception { ResultSetMetaData actualRowsMetaData = actualRows.getMetaData(); JSONArray expectedSchema = (JSONArray) expectedTable.get("table-schema"); assertEquals(expectedSchema.size(), actualRowsMetaData.getColumnCount()); for (int i = 0; i < expectedSchema.size(); i++) assertEquals(expectedSchema.get(i), actualRowsMetaData.getColumnName(i + 1)); for (Object rowObj : (JSONArray) expectedTable.get("table-rows")) { JSONArray row = (JSONArray) rowObj; actualRows.next();/*from w w w . j a v a 2s.co m*/ for (int i = 0; i < row.size(); i++) { Object expected = row.get(i); Object actual; int sqlType = actualRowsMetaData.getColumnType(i + 1); switch (sqlType) { case Types.INTEGER: if (expected instanceof Boolean) expected = (long) ((Boolean) expected ? 1 : 0); actual = actualRows.getLong(i + 1); break; case Types.NULL: case Types.FLOAT: case Types.VARCHAR: actual = actualRows.getObject(i + 1); break; default: throw new RuntimeException("java.sql.Types " + sqlType + " is not supported"); } assertEquals(expected, actual); } } assertFalse(actualRows.next()); }