Java Code Examples for java.sql.ResultSet.getBoolean()

The following are Jave code examples for showing how to use getBoolean() of the java.sql.ResultSet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: cmc-claim-store   File: ClaimMapper.java   View Source Code Vote up 7 votes
@Override
public Claim map(int index, ResultSet result, StatementContext ctx) throws SQLException {

    return new Claim(
        result.getLong("id"),
        result.getString("submitter_id"),
        result.getString("letter_holder_id"),
        result.getString("defendant_id"),
        result.getString("external_id"),
        result.getString("reference_number"),
        toClaimData(result.getString("claim")),
        toLocalDateTimeFromUTC(result.getTimestamp("created_at")),
        result.getTimestamp("issued_on").toLocalDateTime().toLocalDate(),
        result.getTimestamp("response_deadline").toLocalDateTime().toLocalDate(),
        result.getBoolean("more_time_requested"),
        result.getString("submitter_email"),
        toNullableLocalDateTimeFromUTC(result.getTimestamp("responded_at")),
        toNullableResponseData(result.getString("response")),
        result.getString("defendant_email"),
        toNullableCountyCourtJudgment(result.getString("county_court_judgment")),
        toNullableLocalDateTimeFromUTC(result.getTimestamp("county_court_judgment_requested_at")),
        toNullableSettlement(result.getString("settlement")),
        toNullableLocalDateTimeFromUTC(result.getTimestamp("settlement_reached_at")),
        result.getString("sealed_claim_document_management_self_path")
    );
}
 
Example 2
Project: Rubicon   File: PermissionManager.java   View Source Code Vote up 6 votes
/**
 * Loads a {@link Permission} object from the database.
 * @param target the target to query.
 * @param permissionString the permission to query.
 * @return the {@link Permission Permission object} with a negation value or null if it does not exist.
 */
public Permission getPermission(PermissionTarget target, String permissionString) {
    try {
        PreparedStatement selectStatement = MySQL.getConnection()
                .prepareStatement("SELECT `negated` FROM `" + TABLE + "` " +
                        "WHERE `guildid` = ? " +
                        "AND `type` = ? " +
                        "AND `id` = ? " +
                        "AND `permission` = ?;");
        selectStatement.setLong(1, target.getGuild().getIdLong());
        selectStatement.setString(2, String.valueOf(target.getType().getIdentifier()));
        selectStatement.setLong(3, target.getId());
        selectStatement.setString(4, permissionString);
        ResultSet queryResult = selectStatement.executeQuery();
        return queryResult.next()
                ? new Permission(permissionString, queryResult.getBoolean("negated")) // entry with negation value
                : null; // no entry
    } catch (SQLException e) {
        throw new RuntimeException("An unknown error has occurred while fetching database information.", e);
    }
}
 
Example 3
Project: Java-Air-Reservation   File: Passenger.java   View Source Code Vote up 5 votes
/**
 * constructor with the id
 * @param passNo : passport number 
 */
public  Passenger(String passNo){
    conn = DBConnect.connect();
    PreparedStatement pst;
    try {
        String sql = "SELECT * FROM `passenger` WHERE `pass_no`=?";
        pst=conn.prepareStatement(sql);
        pst.setString(1,passNo);
        ResultSet rs;
        rs = pst.executeQuery();
        if (!rs.isBeforeFirst() ) {     
            return;
        } 
        while (rs.next()) {
                this.tel = rs.getString("tel");
                this.paddress = rs.getString("paddress");
                this.fname = rs.getString("fname");
                this.lname = rs.getString("lname");
                this.pass_no = rs.getString("pass_no");
                this.password = rs.getString("password");
                this.dob = rs.getDate("dob");
                this.active  = rs.getBoolean("active");
                this.exist = true;
        }
    } catch (SQLException e) {
        System.out.println("Error : while excicuting prepared statement");
        System.out.println(e);
        System.out.println(e.getErrorCode());
    }
}
 
Example 4
Project: bskyblock   File: MySQLDatabaseHandler.java   View Source Code Vote up 5 votes
@Override
public boolean objectExits(String key) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: checking if " + key + " exists in the database");
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;
    String query = "SELECT  IF ( EXISTS( SELECT * FROM `" + type.getCanonicalName() + "` WHERE `uniqueId` = ?), 1, 0)";
    //String query = "SELECT * FROM `" + type.getCanonicalName() + "` WHERE uniqueId = ?";
    try {
        connection = databaseConnecter.createConnection();
        preparedStatement = connection.prepareStatement(query);
        preparedStatement.setString(1, key);
        resultSet = preparedStatement.executeQuery();
        if (DEBUG)
            plugin.getLogger().info("DEBUG: object exists sql " + preparedStatement.toString());
        if (resultSet.next()) {
            if (DEBUG)
                plugin.getLogger().info("DEBUG: result is " + resultSet.getBoolean(1));
            return resultSet.getBoolean(1);
        }
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        MySQLDatabaseResourceCloser.close(resultSet);
        MySQLDatabaseResourceCloser.close(preparedStatement);
        MySQLDatabaseResourceCloser.close(connection);
    }
    return false;
}
 
Example 5
Project: calcite-avatica   File: AvaticaResultSetConversionsTest.java   View Source Code Vote up 5 votes
public void testGetBoolean(ResultSet resultSet) throws SQLException {
  try {
    resultSet.getBoolean(ordinal);
    fail("Was expecting to throw SQLDataException");
  } catch (Exception e) {
    assertThat(e, isA((Class) SQLDataException.class)); // success
  }
}
 
Example 6
Project: airsonic   File: ArtistDao.java   View Source Code Vote up 5 votes
public Artist mapRow(ResultSet rs, int rowNum) throws SQLException {
    return new Artist(
            rs.getInt(1),
            rs.getString(2),
            rs.getString(3),
            rs.getInt(4),
            rs.getTimestamp(5),
            rs.getBoolean(6),
            rs.getInt(7));
}
 
Example 7
Project: AdamantineShield   File: ContainerLookupResult.java   View Source Code Vote up 5 votes
protected void readResult(ResultSet results) throws SQLException {
	while (results.next()) {
		Vector3i pos = new Vector3i(results.getInt("x"), results.getInt("y"), results.getInt("z"));
		UUID world = UUID.fromString(results.getString("world"));
		ActionType type = ActionType.valueCache[results.getByte("type")];
		String cause = results.getString("cause");
		String data = results.getString("data");
		ItemType item = Sponge.getRegistry().getType(ItemType.class, results.getString("AS_Id.value")).get();
		int count = results.getByte("count");
		int slot = results.getInt("slot");
		boolean rolledBack = results.getBoolean("rolled_back");
		long timestamp = results.getLong("time");
		lines.add(new LookupLine(pos, world, type, cause, data, item, count, slot, rolledBack, timestamp));
	}
}
 
Example 8
Project: burstcoin   File: DigitalGoodsStore.java   View Source Code Vote up 5 votes
private Goods(ResultSet rs) throws SQLException {
    this.id = rs.getLong("id");
    this.dbKey = goodsDbKeyFactory.newKey(this.id);
    this.sellerId = rs.getLong("seller_id");
    this.name = rs.getString("name");
    this.description = rs.getString("description");
    this.tags = rs.getString("tags");
    this.quantity = rs.getInt("quantity");
    this.priceNQT = rs.getLong("price");
    this.delisted = rs.getBoolean("delisted");
    this.timestamp = rs.getInt("timestamp");
}
 
Example 9
Project: Nird2   File: JdbcDatabase.java   View Source Code Vote up 5 votes
@Override
public Contact getContact(Connection txn, ContactId c) throws DbException {
	PreparedStatement ps = null;
	ResultSet rs = null;
	try {
		String sql = "SELECT authorId, name, publicKey,"
				+ " localAuthorId, verified, active"
				+ " FROM contacts"
				+ " WHERE contactId = ?";
		ps = txn.prepareStatement(sql);
		ps.setInt(1, c.getInt());
		rs = ps.executeQuery();
		if (!rs.next()) throw new DbStateException();
		AuthorId authorId = new AuthorId(rs.getBytes(1));
		String name = rs.getString(2);
		byte[] publicKey = rs.getBytes(3);
		AuthorId localAuthorId = new AuthorId(rs.getBytes(4));
		boolean verified = rs.getBoolean(5);
		boolean active = rs.getBoolean(6);
		rs.close();
		ps.close();
		Author author = new Author(authorId, name, publicKey);
		return new Contact(c, author, localAuthorId, verified, active);
	} catch (SQLException e) {
		tryToClose(rs);
		tryToClose(ps);
		throw new DbException(e);
	}
}
 
Example 10
Project: mcClans   File: DatabaseLoader.java   View Source Code Vote up 5 votes
@Override
protected void loadClanPlayers() {
    ResultSet clanPlayersResultSet = databaseConnectionOwner.executeQuery(GET_CLANPLAYERS_QUERY);
    if (clanPlayersResultSet != null) {
        try {
            while (clanPlayersResultSet.next()) {
                String playerName = clanPlayersResultSet.getString("playername");
                int clanPlayerID = clanPlayersResultSet.getInt("clanplayer_id");
                long uuidMostSigBits = clanPlayersResultSet.getLong("uuid_most_sig_bits");
                long uuidLeastSigBits = clanPlayersResultSet.getLong("uuid_least_sig_bits");
                int rankID = clanPlayersResultSet.getInt("rank_id");
                int clanID = clanPlayersResultSet.getInt("clan_id");
                int killsHigh = clanPlayersResultSet.getInt("kills_high");
                int killsMedium = clanPlayersResultSet.getInt("kills_medium");
                int killsLow = clanPlayersResultSet.getInt("kills_low");
                int deathsHigh = clanPlayersResultSet.getInt("deaths_high");
                int deathsMedium = clanPlayersResultSet.getInt("deaths_medium");
                int deathsLow = clanPlayersResultSet.getInt("deaths_low");
                boolean ffProtection = clanPlayersResultSet.getBoolean("ff_protection");
                long lastOnlineTime = clanPlayersResultSet.getLong("last_online_time");

                super.loadedClanPlayer(clanPlayerID, uuidMostSigBits, uuidLeastSigBits, playerName, clanID, rankID, killsHigh, killsMedium,
                        killsLow, deathsHigh, deathsMedium, deathsLow, ffProtection, lastOnlineTime);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
Example 11
Project: DMS   File: UserManager.java   View Source Code Vote up 5 votes
public static boolean[] getOutStatus(String id) throws SQLException {
    boolean[] list = new boolean[2];
    String uid = getUid(id);
    ResultSet rs = DB.executeQuery("SELECT sat, sun FROM goingout_apply WHERE uid=?", uid);
    if (rs.next()) {
        list[0] = rs.getBoolean(1);
        list[1] = rs.getBoolean(2);
    }
    return list;

}
 
Example 12
Project: PTEAssistant   File: UserSettingDao.java   View Source Code Vote up 5 votes
private UserSetting mapRow(ResultSet rs) throws SQLException, ParseException {
    UserSetting us = new UserSetting();
    us.user.uid = rs.getLong("uid");
    us.user.username = rs.getString("username");
    us.user.password = rs.getString("password");
    us.examCode = rs.getString("examCode");
    us.testCentersCriteria.put("countryCode", rs.getString("countryCode"));
    us.testCentersCriteria.put("city", rs.getString("city"));
    us.testCentersCriteria.put("stateCode", rs.getString("stateCode"));
    
    us.apptSearchRule.type = rs.getInt("type");
    us.apptSearchRule.startCalendar = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    us.apptSearchRule.startCalendar.setTime(sdf.parse(rs.getString("startCalendar")));
    String endCalendar = rs.getString("endCalendar");
    if(StringUtils.isNotEmpty(endCalendar)) {
        us.apptSearchRule.endCalendar = Calendar.getInstance();
        us.apptSearchRule.endCalendar.setTime(sdf.parse(endCalendar));
    }
    
    us.applyType = rs.getInt("applyType");
    us.paramVoucherNumber = rs.getString("paramVoucherNumber");

    us.creditCard.put("paymentType", rs.getInt("paymentType"));
    us.creditCard.put("cardNumber", rs.getString("cardNumber"));
    us.creditCard.put("cardHoldersName", rs.getString("cardHoldersName"));
    us.creditCard.put("cardExpYear", rs.getInt("cardExpYear"));
    us.creditCard.put("cardExpMonth", rs.getInt("cardExpMonth"));
    us.creditCard.put("cardSecCode", rs.getString("cardSecCode"));
    
    us.searchSeatOnly = rs.getBoolean("searchSeatOnly");
    us.loopRequestIntervalMS = rs.getLong("loopRequestIntervalMS");
    return us;
}
 
Example 13
Project: burstcoin   File: Poll.java   View Source Code Vote up 5 votes
private Poll(ResultSet rs) throws SQLException {
    this.id = rs.getLong("id");
    this.dbKey = pollDbKeyFactory.newKey(this.id);
    this.name = rs.getString("name");
    this.description = rs.getString("description");
    this.options = (String[])rs.getArray("options").getArray();
    this.minNumberOfOptions = rs.getByte("min_num_options");
    this.maxNumberOfOptions = rs.getByte("max_num_options");
    this.optionsAreBinary = rs.getBoolean("binary_options");
}
 
Example 14
Project: MineDonate   File: UsersShops.java   View Source Code Vote up 4 votes
@Override
public void loadCategoryFromObject ( Object o ) {
	
	ResultSet rs = ( ResultSet ) o ;
	
    try {        	
    	
        while (rs.next()) {
        	
            final ShopInfo info = new ShopInfo(rs.getInt("id"), rs.getInt("id"), rs.getInt("rating"), rs.getString("UUID"), rs.getString("ownerName"), rs.getString("name"), rs.getBoolean("isFreezed"), rs.getString("freezer"), rs.getString("freezReason"), true, rs.getString("moneyType"));
            
            this.addMerch(info);
            
        }
        
    } catch (SQLException e) {
    	
        e.printStackTrace();
        
    }

    MineDonate . logInfo ( "Loaded " + m_Merch . size() + " merch in " + toString ( ) ) ;

}
 
Example 15
Project: mm-system-2017   File: DataAccess.java   View Source Code Vote up 4 votes
@SuppressWarnings("resource") // got warning about stm in case 3 not being closed
@Override
public ArrayList<Meeting> getUserMeetings(int id) throws SQLException {
	ArrayList<Meeting> meeting = new ArrayList<Meeting>();
	Meeting meet = null;
	PreparedStatement stm = c.prepareStatement(SQLStatements.selectUserById);
	stm.setInt(1, id);
	ResultSet rs = stm.executeQuery();

	if (rs.next()) {
		int type = rs.getInt(DataContract.UsersTable.COL_TYPE);
		switch (type) {
		case 2:// Mentor
			stm = c.prepareStatement(SQLStatements.selectMeetingsByMentorId);
			break;
		case 3:// Mentee
			stm = c.prepareStatement(SQLStatements.selectMeetingsByMenteeId);
			break;
		default:
			// TODO: LOG ERROR
			rs.close();
			stm.close();

			return null;
		}
	}

	stm.setInt(1, id);
	rs = stm.executeQuery();
	while (rs.next()) {
		java.sql.Date SDate = rs.getDate(DataContract.MeetingTable.COL_DATE);
		meet = new Meeting(rs.getInt(DataContract.MeetingTable.COL_ACTIVITYID),
				rs.getInt(DataContract.MeetingTable.COL_PAIRID), rs.getInt(DataContract.MeetingTable.COL_MENTORID),
				rs.getInt(DataContract.MeetingTable.COL_MENTEEID), rs.getString(DataContract.MeetingTable.COL_NOTE),
				meetingStatus.valueOf(rs.getInt(DataContract.MeetingTable.COL_STATUS)),
				rs.getString(DataContract.MeetingTable.COL_MENTEEREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTORREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTEEPRIVREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTORPRIVREPORT),
				meetingType.getByValue(rs.getInt(DataContract.MeetingTable.COL_MEETINGTYPE)),
				rs.getString(DataContract.MeetingTable.COL_SUBJECT),
				rs.getString(DataContract.MeetingTable.COL_LOCATION), SDate.getTime(),
				rs.getTime(DataContract.MeetingTable.COL_STARTINGTIME),
				rs.getTime(DataContract.MeetingTable.COL_ENDINGTIME),
				rs.getBoolean(DataContract.MeetingTable.COL_MENTORCOMPLETE),
				rs.getBoolean(DataContract.MeetingTable.COL_MENTEECOMPLETE));
		meeting.add(meet);

	}
	rs.close();
	stm.close();

	return meeting;
}
 
Example 16
Project: open-rmbt   File: Client.java   View Source Code Vote up 4 votes
public long getClientByUuid(final UUID uuid)
{
    resetError();
    
    try
    {
        
        final PreparedStatement st = conn
                .prepareStatement("SELECT client.*, client_type.name AS client_type_name FROM client , client_type WHERE client.client_type_id = client_type.uid AND client.uuid = CAST ( ? AS uuid)");
        st.setString(1, uuid.toString());
        
        final ResultSet rs = st.executeQuery();
        
        if (rs.next())
        {
            uid = rs.getLong("uid");
            this.uuid = UUID.fromString(rs.getString("uuid"));
            client_type_id = rs.getInt("client_type_id");
            client_type_name = rs.getString("client_type_name");
            time = rs.getTimestamp("time");
            time_zone = Helperfunctions.getTimeWithTimeZone(Helperfunctions.getTimezoneId());
            sync_group_id = rs.getInt("sync_group_id");
            sync_code = rs.getString("sync_code");
            tcAccepted = rs.getBoolean("terms_and_conditions_accepted");
            tcAcceptedVersion = rs.getInt("terms_and_conditions_accepted_version");
        }
        else
        {
            // setError("ERROR_DB_GET_CLIENT");
            // errorList.addError(MessageFormat.format(labels.getString("ERROR_DB_GET_CLIENT"),
            // new Object[] {uuid}));
        }
        
        rs.close();
        st.close();
    }
    catch (final SQLException e)
    {
        e.printStackTrace();
        setError("ERROR_DB_GET_CLIENT_SQL");
        // errorList.addError("ERROR_DB_GET_CLIENT_SQL");
    }
    
    return uid;
}
 
Example 17
Project: ralasafe   File: ResultSetReader.java   View Source Code Vote up 4 votes
public Object reader(ResultSet rs, int columnIndex) throws SQLException {
	return new Boolean(rs.getBoolean(columnIndex));
}
 
Example 18
Project: burstcoin   File: TransactionDb.java   View Source Code Vote up 4 votes
static TransactionImpl loadTransaction(Connection con, ResultSet rs) throws NxtException.ValidationException {
    try {

        byte type = rs.getByte("type");
        byte subtype = rs.getByte("subtype");
        int timestamp = rs.getInt("timestamp");
        short deadline = rs.getShort("deadline");
        byte[] senderPublicKey = rs.getBytes("sender_public_key");
        long amountNQT = rs.getLong("amount");
        long feeNQT = rs.getLong("fee");
        byte[] referencedTransactionFullHash = rs.getBytes("referenced_transaction_full_hash");
        int ecBlockHeight = rs.getInt("ec_block_height");
        long ecBlockId = rs.getLong("ec_block_id");
        byte[] signature = rs.getBytes("signature");
        long blockId = rs.getLong("block_id");
        int height = rs.getInt("height");
        long id = rs.getLong("id");
        long senderId = rs.getLong("sender_id");
        byte[] attachmentBytes = rs.getBytes("attachment_bytes");
        int blockTimestamp = rs.getInt("block_timestamp");
        byte[] fullHash = rs.getBytes("full_hash");
        byte version = rs.getByte("version");

        ByteBuffer buffer = null;
        if (attachmentBytes != null) {
            buffer = ByteBuffer.wrap(attachmentBytes);
            buffer.order(ByteOrder.LITTLE_ENDIAN);
        }

        TransactionType transactionType = TransactionType.findTransactionType(type, subtype);
        TransactionImpl.BuilderImpl builder = new TransactionImpl.BuilderImpl(version, senderPublicKey,
                amountNQT, feeNQT, timestamp, deadline,
                transactionType.parseAttachment(buffer, version))
                .referencedTransactionFullHash(referencedTransactionFullHash)
                .signature(signature)
                .blockId(blockId)
                .height(height)
                .id(id)
                .senderId(senderId)
                .blockTimestamp(blockTimestamp)
                .fullHash(fullHash);
        if (transactionType.hasRecipient()) {
            long recipientId = rs.getLong("recipient_id");
            if (! rs.wasNull()) {
                builder.recipientId(recipientId);
            }
        }
        if (rs.getBoolean("has_message")) {
            builder.message(new Appendix.Message(buffer, version));
        }
        if (rs.getBoolean("has_encrypted_message")) {
            builder.encryptedMessage(new Appendix.EncryptedMessage(buffer, version));
        }
        if (rs.getBoolean("has_public_key_announcement")) {
            builder.publicKeyAnnouncement(new Appendix.PublicKeyAnnouncement(buffer, version));
        }
        if (rs.getBoolean("has_encrypttoself_message")) {
            builder.encryptToSelfMessage(new Appendix.EncryptToSelfMessage(buffer, version));
        }
        if (version > 0) {
            builder.ecBlockHeight(ecBlockHeight);
            builder.ecBlockId(ecBlockId);
        }

        return builder.build();

    } catch (SQLException e) {
        throw new RuntimeException(e.toString(), e);
    }
}
 
Example 19
Project: morpheus-core   File: SQLExtractor.java   View Source Code Vote up 2 votes
/**
 * Returns the value from the result set at current row and col index specified
 * @param rs        the result set reference
 * @param colIndex  the result set column index
 * @return          the value extracted from result set
 * @throws SQLException
 */
public boolean getBoolean(ResultSet rs, int colIndex) throws SQLException {
    return rs.getBoolean(colIndex);
}
 
Example 20
Project: parabuild-ci   File: jdbcDatabaseMetaData.java   View Source Code Vote up 1 votes
/**
 * Retrieves whether this database is in read-only mode. <p>
 *
 * <!-- start release-specific documentation -->
 * <div class="ReleaseSpecificDocumentation">
 * <h3>HSQLDB-Specific Information:</h3> <p>
 *
 * Starting with 1.7.2, this makes
 * an SQL call to the new {@link Library#isReadOnlyDatabase} method
 * which provides correct determination of the read-only status for
 * both local and remote database instances.
 * </div>
 * <!-- end release-specific documentation -->
 * @return <code>true</code> if so; <code>false</code> otherwise
 * @exception SQLException if a database access error occurs
 */
public boolean isReadOnly() throws SQLException {

    ResultSet rs =
        execute("CALL \"org.hsqldb.Library.isReadOnlyDatabase\"()");

    rs.next();

    boolean result = rs.getBoolean(1);

    rs.close();

    return result;
}