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.sfs.whichdoctor.dao.AccreditationDAOImpl.java
/** * Load accreditation./*from w w w . j a v a 2s . c om*/ * * @param rs the rs * * @return the accreditation bean * * @throws SQLException the SQL exception */ private AccreditationBean loadAccreditation(final ResultSet rs) throws SQLException { AccreditationBean accreditation = new AccreditationBean(); accreditation.setId(rs.getInt("AccreditationId")); accreditation.setGUID(rs.getInt("GUID")); accreditation.setReferenceGUID(rs.getInt("ReferenceGUID")); accreditation.setCore(rs.getBoolean("Core")); accreditation.setAccreditationClass(rs.getString("AccreditationClass")); accreditation.setAccreditationType(rs.getString("AccreditationType")); accreditation.setAbbreviation(rs.getString("AccreditationTypeAbbreviation")); accreditation.setSpecialtyType(rs.getString("SpecialtyTypeClass")); accreditation.setSpecialtyTypeAbbreviation(rs.getString("SpecialtyTypeAbbreviation")); accreditation.setSpecialtySubType(rs.getString("SpecialtyTypeName")); accreditation.setWeeksApproved(rs.getInt("WeeksApproved")); accreditation.setWeeksCertified(rs.getInt("WeeksCertified")); accreditation.setNote(rs.getString("Note")); try { accreditation.setAccreditationDate(rs.getDate("AccreditationDate")); } catch (Exception e) { dataLogger.debug("Error parsing AccreditationDate: " + e.getMessage()); } accreditation.setActive(rs.getBoolean("Active")); try { accreditation.setCreatedDate(rs.getTimestamp("CreatedDate")); } catch (SQLException e) { dataLogger.debug("Error parsing CreatedDate: " + e.getMessage()); } accreditation.setCreatedBy(rs.getString("CreatedBy")); try { accreditation.setModifiedDate(rs.getTimestamp("ModifiedDate")); } catch (SQLException e) { dataLogger.debug("Error parsing ModifiedDate: " + e.getMessage()); } accreditation.setModifiedBy(rs.getString("ModifiedBy")); try { accreditation.setExportedDate(rs.getTimestamp("ExportedDate")); } catch (SQLException e) { dataLogger.debug("Error parsing ExportedDate: " + e.getMessage()); } accreditation.setExportedBy(rs.getString("ExportedBy")); return accreditation; }
From source file:cz.incad.kramerius.processes.impl.DatabaseProcessManager.java
@Override public boolean isAuthTokenClosed(String authToken) { Connection connection = connectionProvider.get(); if (connection == null) throw new NotReadyException("connection not ready"); List<Boolean> flags = new JDBCQueryTemplate<Boolean>(connection) { @Override// w w w. j a v a 2 s . c om public boolean handleRow(ResultSet rs, List<Boolean> returnsList) throws SQLException { returnsList.add(rs.getBoolean("token_active")); return super.handleRow(rs, returnsList); } }.executeQuery("select token_active from processes where auth_token=?", authToken); // no flags if (flags.isEmpty()) return true; for (Boolean flag : flags) { if (!flag.booleanValue()) return true; } return false; }
From source file:com.sfs.whichdoctor.dao.WorkshopDAOImpl.java
/** * Load workshop./*from ww w . j av a 2 s. co m*/ * * @param rs the rs * @param fullResults the full results * @return the workshop bean * @throws SQLException the SQL exception */ private WorkshopBean loadWorkshop(final ResultSet rs, final boolean fullResults) throws SQLException { WorkshopBean workshop = new WorkshopBean(); workshop.setId(rs.getInt("WorkshopId")); workshop.setGUID(rs.getInt("GUID")); workshop.setReferenceGUID(rs.getInt("ReferenceGUID")); workshop.setType(rs.getString("Type")); try { workshop.setWorkshopDate(rs.getDate("Date")); } catch (SQLException e) { workshop.setWorkshopDate(null); } workshop.setMemo(rs.getString("Memo")); workshop.setActive(rs.getBoolean("Active")); try { workshop.setCreatedDate(rs.getTimestamp("CreatedDate")); } catch (SQLException sqe) { dataLogger.debug("Error reading CreatedDate: " + sqe.getMessage()); } workshop.setCreatedBy(rs.getString("CreatedBy")); try { workshop.setModifiedDate(rs.getTimestamp("ModifiedDate")); } catch (SQLException sqe) { dataLogger.debug("Error reading ModifiedDate: " + sqe.getMessage()); } workshop.setModifiedBy(rs.getString("ModifiedBy")); return workshop; }
From source file:com.concursive.connect.web.modules.common.social.rating.dao.Rating.java
/** * @param rs the resultset to build the record from * @param uniqueField// w w w. java 2s. c o m */ private void buildRecord(ResultSet rs, String primaryKeyField, String uniqueField, boolean hasInappropriate) throws SQLException { id = rs.getInt(primaryKeyField); objectId = rs.getInt(uniqueField); rating = DatabaseUtils.getInt(rs, "rating"); if (hasInappropriate) { inappropriate = rs.getBoolean("inappropriate"); } entered = rs.getTimestamp("entered"); enteredby = DatabaseUtils.getInt(rs, "enteredby"); projectId = DatabaseUtils.getInt(rs, "project_id"); }
From source file:edu.jhu.pha.vospace.meta.MySQLMetaStore2.java
@Override public NodeInfo getNodeInfo(final VospaceId identifier) { return DbPoolServlet.goSql("Retrieving node info", "select rev, deleted, nodes.mtime, nodes.size, mimetype, chunked_name from nodes " + "JOIN containers ON nodes.container_id = containers.container_id " + "JOIN user_identities ON containers.user_id = user_identities.user_id " + "LEFT JOIN chunked_uploads ON nodes.node_id = chunked_uploads.node_id " + "WHERE current_rev = 1 and container_name = ? and path = ? and identity = ?", new SqlWorker<NodeInfo>() { @Override/*from www.ja v a 2s . co m*/ public NodeInfo go(Connection conn, PreparedStatement stmt) throws SQLException { NodeInfo info = new NodeInfo(); stmt.setString(1, identifier.getNodePath().getContainerName()); stmt.setString(2, identifier.getNodePath().getNodeRelativeStoragePath()); stmt.setString(3, owner); ResultSet resSet = stmt.executeQuery(); if (resSet.next()) { info.setRevision(resSet.getInt("rev")); info.setDeleted(resSet.getBoolean("deleted")); info.setMtime(new Date(resSet.getTimestamp("mtime").getTime())); info.setSize(resSet.getLong("size")); info.setContentType(resSet.getString("mimetype")); info.setChunkedName(resSet.getString("chunked_name")); } else { throw new NotFoundException("NodeNotFound"); } return info; } }); }
From source file:com.apatar.webdav.WebDavNode.java
@Override protected void TransformTDBtoRDB(int mode) { try {/* w ww. ja v a 2 s . c o m*/ DataBaseTools.completeTransfer(); TableInfo ti = getTiForConnection(IN_CONN_POINT_NAME); ResultSet rs = DataBaseTools.getRSWithAllFields(ti.getTableName(), ApplicationData.tempDataBase.getJdbcParams(), ApplicationData.getTempDataBaseInfo()); WebdavResource resource = null; while (rs.next()) { boolean isFolder = rs.getBoolean("isFolder"); resource = getBinding(); // pathRes - path to resource String pathRes = convertHttpToString(resource.getHttpURL()); // path - inner path from db String path = rs.getString("Path"); if (path.length() > 0) { if (separator.equals(path.substring(0, 1)) || "\\".equals(path.substring(0, 1))) { pathRes += path; } else { pathRes = pathRes + separator + path; } } if (isFolder) { resource.mkcolMethod(pathRes); } else { InputStream in = rs.getBinaryStream("Content"); if (null != in) { resource.putMethod(pathRes, in); in.close(); } else { // if Content field is null, but String_Content field is // not null String strContent = rs.getString("String_Content"); if (null != strContent && !"".equals(strContent)) { byte[] bytes = strContent.getBytes(); resource.putMethod(pathRes, bytes); } else { resource.putMethod(pathRes, ""); } } } if (!ApplicationData.ProcessingProgress.Step()) { return; } ApplicationData.ProcessingProgress.Log("Uploading resource: " + pathRes); } } catch (Exception e1) { ApplicationData.ProcessingProgress.Log(e1); e1.printStackTrace(); } finally { DataBaseTools.completeTransfer(); } }
From source file:com.ewcms.component.interaction.dao.InteractionDAO.java
@Override public List<Speak> findSpeakByInteractionId(int interactionId, String username, int page, int row) { String sql = "Select * From plugin_interaction_speak " + "Where interaction_id = ? And (checked = true Or username=?) " + "Order By date desc Limit ? OffSet ?"; username = (username == null ? "" : username); int offset = page * row; List<Speak> list = jdbcTemplate.query(sql, new Object[] { interactionId, username, row, offset }, new RowMapper<Speak>() { @Override//from w w w.j a v a 2 s .com public Speak mapRow(ResultSet rs, int rowNum) throws SQLException { Speak vo = new Speak(); vo.setUsername(rs.getString("username")); vo.setName(rs.getString("name")); vo.setContent(rs.getString("content")); vo.setIp(rs.getString("ip")); vo.setChecked(rs.getBoolean("checked")); vo.setDate(rs.getTimestamp("date")); vo.setInteractionId(rs.getInt("interaction_id")); vo.setName(rs.getString("name")); return vo; } }); return list; }
From source file:com.alfaariss.oa.engine.requestor.jdbc.JDBCRequestor.java
/** * Creates a Requestor object.//from www . j a v a 2 s . c o m * <br> * @param rsRequestor containing the requestor information * @return Requestor object * @throws RequestorException if creation fails */ private Requestor getRequestor(ResultSet rsRequestor, ResultSet rsProperties) throws RequestorException { Requestor oRequestor = null; try { String sID = rsRequestor.getString(COLUMN_ID); String sFriendlyName = rsRequestor.getString(COLUMN_FRIENDLYNAME); if (sFriendlyName == null) { StringBuffer sbWarn = new StringBuffer("No '"); sbWarn.append(COLUMN_FRIENDLYNAME); sbWarn.append("' available for requestor with id: "); sbWarn.append(sID); _logger.error(sbWarn.toString()); throw new RequestorException(SystemErrors.ERROR_RESOURCE_RETRIEVE); } boolean bEnabled = rsRequestor.getBoolean(COLUMN_ENABLED); Properties prop = new Properties(); while (rsProperties.next()) { String sName = rsProperties.getString(JDBCRequestor.COLUMN_PROPERTY_NAME); Object value = rsProperties.getString(JDBCRequestor.COLUMN_PROPERTY_VALUE); prop.put(sName, value); } _logger.debug("Retrieved properties: " + prop); Date dLastModified = null; try { dLastModified = rsRequestor.getTimestamp(JDBCRequestor.COLUMN_DATELASTMODIFIED); } catch (Exception e) { _logger.info("No " + JDBCRequestor.COLUMN_DATELASTMODIFIED + " column found for requestor '" + sID + "'; ignoring."); } oRequestor = new Requestor(sID, sFriendlyName, bEnabled, prop, dLastModified); } catch (RequestorException e) { throw e; } catch (SQLException e) { _logger.error("Can not read from database", e); throw new RequestorException(SystemErrors.ERROR_RESOURCE_RETRIEVE); } catch (Exception e) { _logger.fatal("Internal error during create of a requestor", e); throw new RequestorException(SystemErrors.ERROR_INTERNAL); } return oRequestor; }
From source file:com.havoc.hotel.admin.dao.impl.UserDAOImpl.java
@Override public User getById(int userId) throws SQLException { return (User) jdbcTemplate.query(SQLConstant.USER_GETById, new Object[] { userId }, new ResultSetExtractor<User>() { @Override/*from w w w . ja v a2 s.co m*/ public User extractData(ResultSet rs) throws SQLException, DataAccessException { User u = null; if (rs.next()) { u = new User(); u.setUserId(rs.getInt("user_id")); u.setFirstName(rs.getString("first_name")); u.setLastName(rs.getString("last_name")); u.setEmail(rs.getString("email")); u.setUsername(rs.getString("username")); u.setPassword(rs.getString("password")); u.setRoleId(rs.getInt("role_id")); u.setAddedDate(rs.getDate("added_date")); u.setStatus(rs.getBoolean("status")); } return u; } }); }
From source file:com.havoc.hotel.admin.dao.impl.UserDAOImpl.java
@Override public User authenticate(String username, String password) { return (User) jdbcTemplate.query(SQLConstant.USER_AUTHENTICATE, new Object[] { username, password }, new ResultSetExtractor<User>() { @Override/*from ww w .j ava 2 s . c om*/ public User extractData(ResultSet rs) throws SQLException, DataAccessException { User u = null; if (rs.next()) { u = new User(); u.setUserId(rs.getInt("user_id")); u.setFirstName(rs.getString("first_name")); u.setLastName(rs.getString("last_name")); u.setEmail(rs.getString("email")); u.setUsername(rs.getString("username")); u.setPassword(rs.getString("password")); u.setRoleId(rs.getInt("role_id")); u.setAddedDate(rs.getDate("added_date")); u.setStatus(rs.getBoolean("status")); } return u; } }); }