List of usage examples for java.sql ResultSet getBoolean
boolean getBoolean(String columnLabel) throws SQLException;
ResultSet
object as a boolean
in the Java programming language. From source file:com.stehno.sjdbcx.reflection.extractor.RowMapperExtractor.java
public RowMapper extract(final Method method) { final com.stehno.sjdbcx.annotation.RowMapper mapper = AnnotationUtils.getAnnotation(method, com.stehno.sjdbcx.annotation.RowMapper.class); if (mapper == null) { Class mappedType = method.getReturnType(); if (Collection.class.isAssignableFrom(mappedType)) { mappedType = (Class) ((ParameterizedType) method.getGenericReturnType()) .getActualTypeArguments()[0]; } else if (mappedType.isArray()) { throw new UnsupportedOperationException("Auto-mapping for array return types is not yet supported"); } else if (mappedType.isPrimitive()) { if (mappedType == int.class || mappedType == long.class) { return new SingleColumnRowMapper(); } else if (mappedType == boolean.class) { return new RowMapper<Boolean>() { @Override/*from ww w .j av a 2s . co m*/ public Boolean mapRow(final ResultSet resultSet, final int i) throws SQLException { return resultSet.getBoolean(1); } }; } } return new BeanPropertyRowMapper(mappedType); } else { final String extractKey = mapper.value(); if (StringUtils.isEmpty(extractKey)) { return resolve((Class<RowMapper>) mapper.type()); } else { return resolve(extractKey); } } }
From source file:ru.org.linux.user.MemoriesDao.java
/** * get number of memories/favs for topic * @return list(0) - memories, list(1) - favs *///from w w w. j av a 2 s .com public List<Integer> getTopicStats(int topic) { final List<Integer> res = Lists.newArrayList(0, 0); jdbcTemplate.query("SELECT watch, count(*) FROM memories WHERE topic=? GROUP BY watch", new RowCallbackHandler() { @Override public void processRow(ResultSet rs) throws SQLException { if (rs.getBoolean("watch")) { res.set(0, rs.getInt("count")); } else { res.set(1, rs.getInt("count")); } } }, topic); return res; }
From source file:com.springsource.greenhouse.account.PictureUrlMapper.java
public String mapRow(ResultSet rs, int row) throws SQLException { Gender gender = Gender.valueOf(rs.getString("gender").charAt(0)); return urlFactory.pictureUrl(rs.getLong("id"), pictureSize, rs.getBoolean("pictureSet"), gender); }
From source file:com.flexive.core.Database.java
/** * Load a FxString from a translation table * * @param con an open connection * @param table the base table (NOT the one with translations!) * @param column the name of the columns from the translations table to load * @param whereClause mandatory where clause * @return FxString created from the data table * @throws SQLException if a database error occured */// www. jav a 2 s . c om public static FxString loadFxString(Connection con, String table, String column, String whereClause) throws SQLException { Statement stmt = null; Map<Long, String> hmTrans = new HashMap<Long, String>(10); long defaultLanguageId = -1; try { stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT LANG, DEFLANG, " + column + " FROM " + table + DatabaseConst.ML + " WHERE " + whereClause); while (rs != null && rs.next()) { hmTrans.put(rs.getLong(1), rs.getString(3)); if (rs.getBoolean(2)) { defaultLanguageId = rs.getInt(1); } } } finally { if (stmt != null) stmt.close(); } return new FxString(defaultLanguageId, hmTrans); }
From source file:io.kahu.hawaii.util.spring.AbstractDBRepository.java
protected Boolean getBoolean(final ResultSet rs, final int columnIndex) throws SQLException { boolean result = rs.getBoolean(columnIndex); return rs.wasNull() ? null : result; }
From source file:com.flexive.core.Database.java
/** * Load a FxString from the content data * * @param con an open connection * @param column the name of the column from the translations table to load * @param whereClause mandatory where clause * @return FxString created from the data table * @throws SQLException if a database error occurred *//*www . j a v a 2 s.c o m*/ public static FxString loadContentDataFxString(Connection con, String column, String whereClause) throws SQLException { Statement stmt = null; Map<Long, String> hmTrans = new HashMap<Long, String>(10); int defaultLanguageId = -1; try { stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT LANG, ISMLDEF, " + column + " FROM " + DatabaseConst.TBL_CONTENT_DATA + " WHERE " + whereClause); while (rs != null && rs.next()) { hmTrans.put(rs.getLong(1), rs.getString(3)); if (rs.getBoolean(2)) { defaultLanguageId = rs.getInt(1); } } } finally { if (stmt != null) stmt.close(); } return new FxString(defaultLanguageId, hmTrans); }
From source file:com.monkeyk.sos.infrastructure.jdbc.UserRowMapper.java
@Override public User mapRow(ResultSet rs, int i) throws SQLException { User user = new User(); user.id(rs.getInt("id")); user.guid(rs.getString("guid")); user.archived(rs.getBoolean("archived")); user.createTime(rs.getTimestamp("create_time").toLocalDateTime()); user.email(rs.getString("email")); user.phone(rs.getString("phone")); user.password(rs.getString("password")); user.username(rs.getString("username")); user.lastLoginTime(rs.getTimestamp("last_login_time")); return user;/*from w w w. j a v a 2 s .co m*/ }
From source file:io.kahu.hawaii.util.spring.AbstractDBRepository.java
protected Boolean getBoolean(final ResultSet rs, final String columnLabel) throws SQLException { boolean result = rs.getBoolean(columnLabel); return rs.wasNull() ? null : result; }
From source file:cc.cicadabear.profile.infrastructure.jdbc.UserRowMapper.java
@Override public User mapRow(ResultSet rs, int i) throws SQLException { User user = new User(); user.id(rs.getInt("id")); user.guid(rs.getString("guid")); user.archived(rs.getBoolean("archived")); user.createTime(rs.getTimestamp("create_time").toLocalDateTime()); user.email(rs.getString("email")); user.phone(rs.getString("phone")); user.password(rs.getString("password")); user.salt(rs.getString("salt")); user.setLocked(rs.getInt("locked")); user.setStatus(rs.getInt("status")); user.username(rs.getString("username")); user.lastLoginTime(rs.getTimestamp("last_login_time")); return user;//w w w .ja va2 s . c om }
From source file:com.wso2telco.proxy.util.DBUtils.java
/** * Get Operators' Properties.//from www . j ava 2 s. c o m * * @return operators properties map. * @throws SQLException on errors. * @throws NamingException on errors. */ public static Map<String, Operator> getOperatorProperties() throws SQLException, NamingException { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; Map<String, Operator> operatorProperties = new HashMap<String, Operator>(); String queryToGetOperatorProperties = "SELECT ID, operatorName, requiredIPValidation, ipHeader FROM operators"; try { connection = getConnectDBConnection(); preparedStatement = connection.prepareStatement(queryToGetOperatorProperties); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) { Operator operator = new Operator(); int operatorId = resultSet.getInt(AuthProxyConstants.ID); String operatorName = resultSet.getString(AuthProxyConstants.OPERATOR_NAME); boolean requiredIPValidation = resultSet.getBoolean(AuthProxyConstants.REQUIRED_IP_VALIDATION); String ipHeader = resultSet.getString(AuthProxyConstants.IP_HEADER); operator.setOperatorId(operatorId); operator.setOperatorName(operatorName); operator.setRequiredIpValidation(requiredIPValidation); operator.setIpHeader(ipHeader); operatorProperties.put(operatorName, operator); } } catch (SQLException e) { throw new SQLException("Error occurred while retrieving operator properties.", e); } catch (NamingException e) { throw new ConfigurationException("DataSource could not be found in mobile-connect.xml"); } finally { closeAllConnections(preparedStatement, connection, resultSet); } return operatorProperties; }