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.adito.networkplaces.JDBCNetworkPaceDatabase.java
/** * Build the network place from the result set. * //from ww w . j ava2s. co m * @param rs * @return NetworkPlace * @throws Exception */ NetworkPlace buildNetworkPlace(ResultSet resultSet) throws Exception { int realmId = resultSet.getInt("realm_id"); int resourceId = resultSet.getInt("resource_id"); String scheme = resultSet.getString("scheme"); String shortName = resultSet.getString("short_name"); String description = resultSet.getString("description"); String host = resultSet.getString("host"); String path = resultSet.getString("path"); int port = resultSet.getInt("port"); String username = resultSet.getString("username"); String password = resultSet.getString("password"); boolean readOnly = resultSet.getBoolean("read_only"); boolean allowRecursive = resultSet.getBoolean("allow_resursive"); boolean noDelete = resultSet.getBoolean("no_delete"); boolean showHidden = resultSet.getBoolean("show_hidden"); boolean autoStart = resultSet.getBoolean("auto_start"); Calendar dateCreated = JDBCUtil.getCalendar(resultSet, "date_created"); Calendar dateAmended = JDBCUtil.getCalendar(resultSet, "date_amended"); return new DefaultNetworkPlace(realmId, resourceId, scheme, shortName, description, host, path, port, username, password, NetworkPlace.TYPE_NORMAL, readOnly, allowRecursive, noDelete, showHidden, autoStart, dateCreated, dateAmended); }
From source file:com.sfs.whichdoctor.dao.EmailDAOImpl.java
/** * Load the EmailBean from the database. * * @param rs the rs//w w w. j a v a 2 s .c o m * @return the email bean * @throws SQLException the sQL exception */ private EmailBean loadEmail(final ResultSet rs) throws SQLException { EmailBean emailAddress = new EmailBean(); emailAddress.setId(rs.getInt("EmailId")); emailAddress.setGUID(rs.getInt("GUID")); emailAddress.setReferenceGUID(rs.getInt("ReferenceGUID")); emailAddress.setContactClass(rs.getString("ContactClass")); emailAddress.setContactType(rs.getString("ContactType")); emailAddress.setDescription(rs.getString("Description")); emailAddress.setEmail(rs.getString("Email")); emailAddress.setEmailQuestions(rs.getBoolean("EmailQuestions")); emailAddress.setReturnedMail(rs.getBoolean("ReturnedMail")); emailAddress.setRequestNoMail(rs.getBoolean("RequestNoMail")); emailAddress.setPrimary(rs.getBoolean("PrimaryEmail")); emailAddress.setActive(rs.getBoolean("Active")); try { emailAddress.setCreatedDate(rs.getTimestamp("CreatedDate")); } catch (SQLException sqe) { dataLogger.debug("Error loading CreatedDate: " + sqe.getMessage()); } emailAddress.setCreatedBy(rs.getString("CreatedBy")); try { emailAddress.setModifiedDate(rs.getTimestamp("ModifiedDate")); } catch (SQLException sqe) { dataLogger.debug("Error loading ModifiedDate: " + sqe.getMessage()); } emailAddress.setModifiedBy(rs.getString("ModifiedBy")); try { emailAddress.setExportedDate(rs.getTimestamp("ExportedDate")); } catch (SQLException sqe) { dataLogger.debug("Error loading ExportedDate: " + sqe.getMessage()); } emailAddress.setExportedBy(rs.getString("ExportedBy")); return emailAddress; }
From source file:com.l2jfree.gameserver.instancemanager.ClanHallManager.java
/** Load All Clan Hall */ private final void load() { Connection con = null;/* w w w .j av a 2 s . c o m*/ try { int id, ownerId, lease, grade = 0; String Name, Desc, Location; long paidUntil = 0; boolean paid = false; PreparedStatement statement; ResultSet rs; con = L2DatabaseFactory.getInstance().getConnection(con); statement = con.prepareStatement("SELECT * FROM clanhall ORDER BY id"); rs = statement.executeQuery(); while (rs.next()) { id = rs.getInt("id"); Name = rs.getString("name"); ownerId = rs.getInt("ownerId"); lease = rs.getInt("lease"); Desc = rs.getString("desc"); Location = rs.getString("location"); paidUntil = rs.getLong("paidUntil"); grade = rs.getInt("Grade"); paid = rs.getBoolean("paid"); ClanHall ch = new ClanHall(id, Name, ownerId, lease, Desc, Location, paidUntil, grade, paid); if (ownerId == 0) { _freeClanHall.put(id, ch); } else { L2Clan clan = ClanTable.getInstance().getClan(ownerId); if (clan != null) { _clanHall.put(id, ch); clan.setHasHideout(id); } else { _freeClanHall.put(id, ch); ch.free(); AuctionManager.getInstance().initNPC(id); } } _allClanHalls.put(id, ch); } statement.close(); _log.info("ClanHallManager: loaded " + getClanHalls().size() + " clan halls"); _log.info("ClanHallManager: loaded " + getFreeClanHalls().size() + " free clan halls"); ClanHall[] allHalls = _allClanHalls.values().toArray(new ClanHall[_allClanHalls.size()]); FastList<ClanHall> townHalls = new FastList<ClanHall>(); for (Town t : _towns) { for (ClanHall ch : allHalls) if (ch.getLocation().equals(t.toString()) && ch.getSiege() == null) townHalls.add(ch); _townClanHalls.put(t.getId(), townHalls.toArray(new ClanHall[townHalls.size()])); _log.info("ClanHallManager: " + townHalls.size() + " halls in " + t.toString()); townHalls.clear(); } _loaded = true; } catch (SQLException e) { _log.fatal("Exception: ClanHallManager.load(): " + e.getMessage(), e); } finally { L2DatabaseFactory.close(con); } }
From source file:com.opencsv.ResultSetHelperService.java
private String getColumnValue(ResultSet rs, int colType, int colIndex, boolean trim, String dateFormatString, String timestampFormatString) throws SQLException, IOException { String value = ""; switch (colType) { case Types.BIT: case Types.JAVA_OBJECT: // Once Java 7 is the minimum supported version. // value = Objects.toString(rs.getObject(colIndex), ""); value = ObjectUtils.toString(rs.getObject(colIndex), ""); break;//w ww. j a v a 2s. com case Types.BOOLEAN: // Once Java 7 is the minimum supported version. // value = Objects.toString(rs.getBoolean(colIndex)); value = ObjectUtils.toString(rs.getBoolean(colIndex)); break; case Types.NCLOB: // todo : use rs.getNClob case Types.CLOB: Clob c = rs.getClob(colIndex); if (c != null) { StrBuilder sb = new StrBuilder(); sb.readFrom(c.getCharacterStream()); value = sb.toString(); } break; case Types.BIGINT: // Once Java 7 is the minimum supported version. // value = Objects.toString(rs.getLong(colIndex)); value = ObjectUtils.toString(rs.getLong(colIndex)); break; case Types.DECIMAL: case Types.REAL: case Types.NUMERIC: // Once Java 7 is the minimum supported version. // value = Objects.toString(rs.getBigDecimal(colIndex), ""); value = ObjectUtils.toString(rs.getBigDecimal(colIndex), ""); break; case Types.DOUBLE: // Once Java 7 is the minimum supported version. // value = Objects.toString(rs.getDouble(colIndex)); value = ObjectUtils.toString(rs.getDouble(colIndex)); break; case Types.FLOAT: // Once Java 7 is the minimum supported version. // value = Objects.toString(rs.getFloat(colIndex)); value = ObjectUtils.toString(rs.getFloat(colIndex)); break; case Types.INTEGER: case Types.TINYINT: case Types.SMALLINT: // Once Java 7 is the minimum supported version. // value = Objects.toString(rs.getInt(colIndex)); value = ObjectUtils.toString(rs.getInt(colIndex)); break; case Types.DATE: java.sql.Date date = rs.getDate(colIndex); if (date != null) { SimpleDateFormat df = new SimpleDateFormat(dateFormatString); value = df.format(date); } break; case Types.TIME: // Once Java 7 is the minimum supported version. // value = Objects.toString(rs.getTime(colIndex), ""); value = ObjectUtils.toString(rs.getTime(colIndex), ""); break; case Types.TIMESTAMP: value = handleTimestamp(rs.getTimestamp(colIndex), timestampFormatString); break; case Types.NVARCHAR: // todo : use rs.getNString case Types.NCHAR: // todo : use rs.getNString case Types.LONGNVARCHAR: // todo : use rs.getNString case Types.LONGVARCHAR: case Types.VARCHAR: case Types.CHAR: String columnValue = rs.getString(colIndex); if (trim && columnValue != null) { value = columnValue.trim(); } else { value = columnValue; } break; default: value = ""; } if (rs.wasNull() || value == null) { value = ""; } return value; }
From source file:iddb.runtime.db.model.dao.impl.mysql.PenaltyDAOImpl.java
/** * @param penalty//w ww . j a va 2 s. co m * @param rs * @throws SQLException */ private void loadPenalty(Penalty penalty, ResultSet rs) throws SQLException { penalty.setKey(rs.getLong("id")); penalty.setPlayer(rs.getLong("playerid")); penalty.setAdmin(rs.getLong("adminid")); penalty.setType(rs.getInt("type")); penalty.setReason(rs.getString("reason")); penalty.setDuration(rs.getLong("duration")); penalty.setSynced(rs.getBoolean("synced")); penalty.setActive(rs.getBoolean("active")); penalty.setCreated(rs.getTimestamp("created")); penalty.setUpdated(rs.getTimestamp("updated")); }
From source file:com.sfs.whichdoctor.dao.PhoneDAOImpl.java
/** * Load phone bean from the result set./*from ww w .j av a 2 s .c o m*/ * * @param rs the rs * @return the phone bean * @throws SQLException the sQL exception */ private PhoneBean loadPhone(final ResultSet rs) throws SQLException { PhoneBean phoneNumber = new PhoneBean(); phoneNumber.setId(rs.getInt("PhoneId")); phoneNumber.setGUID(rs.getInt("GUID")); phoneNumber.setReferenceGUID(rs.getInt("ReferenceGUID")); phoneNumber.setContactType(rs.getString("ContactType")); phoneNumber.setDescription(rs.getString("Description")); phoneNumber.setNumber(rs.getString("PhoneNum")); phoneNumber.setExtension(rs.getString("Extension")); phoneNumber.setAreaCode(rs.getInt("AreaCode")); phoneNumber.setCountryCode(rs.getInt("CountryCode")); phoneNumber.setPrimary(rs.getBoolean("PrimaryPhone")); phoneNumber.setActive(rs.getBoolean("Active")); try { phoneNumber.setCreatedDate(rs.getTimestamp("CreatedDate")); } catch (SQLException sqe) { dataLogger.debug("Error reading CreatedDate: " + sqe.getMessage()); } phoneNumber.setCreatedBy(rs.getString("CreatedBy")); try { phoneNumber.setModifiedDate(rs.getTimestamp("ModifiedDate")); } catch (SQLException sqe) { dataLogger.debug("Error reading ModifiedDate: " + sqe.getMessage()); } phoneNumber.setModifiedBy(rs.getString("ModifiedBy")); try { phoneNumber.setExportedDate(rs.getTimestamp("ExportedDate")); } catch (SQLException sqe) { dataLogger.debug("Error reading ExportedDate: " + sqe.getMessage()); } phoneNumber.setExportedBy(rs.getString("ExportedBy")); return phoneNumber; }
From source file:com.icsshs.datatransfer.database.impl.QueryBeanProcessor.java
/** * Convert a <code>ResultSet</code> column into an object. Simple * implementations could just call <code>rs.getObject(index)</code> while * more complex implementations could perform type manipulation to match * the column's type to the bean property type. * * <p>// ww w .jav a 2s . c o m * This implementation calls the appropriate <code>ResultSet</code> getter * method for the given property type to perform the type conversion. If * the property type doesn't match one of the supported * <code>ResultSet</code> types, <code>getObject</code> is called. * </p> * * @param rs The <code>ResultSet</code> currently being processed. It is * positioned on a valid row before being passed into this method. * * @param index The current column index being processed. * * @param propType The bean property type that this column needs to be * converted into. * * @throws SQLException if a database access error occurs * * @return The object from the <code>ResultSet</code> at the given column * index after optional type processing or <code>null</code> if the column * value was SQL NULL. */ protected Object processColumn(ResultSet rs, int index, Class<?> propType) throws SQLException { if (!propType.isPrimitive() && rs.getObject(index) == null) { return null; } if (propType.equals(String.class)) { return rs.getString(index); } else if (propType.equals(Integer.TYPE) || propType.equals(Integer.class)) { return Integer.valueOf(rs.getInt(index)); } else if (propType.equals(Boolean.TYPE) || propType.equals(Boolean.class)) { return Boolean.valueOf(rs.getBoolean(index)); } else if (propType.equals(Long.TYPE) || propType.equals(Long.class)) { return Long.valueOf(rs.getLong(index)); } else if (propType.equals(Double.TYPE) || propType.equals(Double.class)) { return Double.valueOf(rs.getDouble(index)); } else if (propType.equals(Float.TYPE) || propType.equals(Float.class)) { return Float.valueOf(rs.getFloat(index)); } else if (propType.equals(Short.TYPE) || propType.equals(Short.class)) { return Short.valueOf(rs.getShort(index)); } else if (propType.equals(Byte.TYPE) || propType.equals(Byte.class)) { return Byte.valueOf(rs.getByte(index)); } else if (propType.equals(Timestamp.class)) { return rs.getTimestamp(index); } else if (propType.equals(byte[].class)) { return rs.getBytes(index); } else { return rs.getObject(index); } }
From source file:mom.trd.opentheso.bdd.helper.GpsHelper.java
public boolean isHaveCoordinate(HikariDataSource ds, String id_concept, String id_theso) { Connection conn;/*from w ww. j av a 2 s. co m*/ Statement stmt; ResultSet resultSet; boolean existe = false; try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "select gps from concept where " + "id_concept ='" + id_concept + "'" + " and id_thesaurus = '" + id_theso + "'"; resultSet = stmt.executeQuery(query); if (resultSet.next()) { existe = resultSet.getBoolean("gps"); } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while Add coordonnes : " + id_concept, sqle); } return existe; }
From source file:com.havoc.hotel.admin.dao.impl.BookingDAOImpl.java
private Booking mapData(ResultSet rs) throws SQLException { Booking b = new Booking(); b.setBookingId(rs.getInt("booking_id")); b.setFirstName(rs.getString("first_name")); b.setLastName(rs.getString("last_name")); Room r = new Room(); r.setRoomId(rs.getInt("room_id")); r.setRoomPrice(rs.getInt("room_price")); r.setRoomNumber(rs.getInt("room_number")); b.setRoom(r);// ww w.j a v a 2 s .c om b.setCheckinDate(rs.getDate("checkin_date")); b.setTotalDays(rs.getInt("total_days")); b.setTotalNights(rs.getInt("total_nights")); b.setCheckoutDate(rs.getDate("checkout_date")); Customer c = new Customer(); c.setCustomerId(rs.getInt("customer_id")); b.setCustomer(c); b.setTotalPrice(rs.getInt("total_price")); b.setPdf(rs.getString("pdf")); b.setStatus(rs.getBoolean("status")); return b; }