當前位置: 首頁>>代碼示例>>Java>>正文


Java ResultSet.getInt方法代碼示例

本文整理匯總了Java中java.sql.ResultSet.getInt方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultSet.getInt方法的具體用法?Java ResultSet.getInt怎麽用?Java ResultSet.getInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.sql.ResultSet的用法示例。


在下文中一共展示了ResultSet.getInt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: map

import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
public Monitor map(int index, ResultSet r, StatementContext ctx) throws SQLException {

    int status = r.getInt("STATUS");
    boolean isUsable = true;
    if (status == 0) {
        isUsable = false;
    }

    Monitor monitor = Monitor.builder()
            .monitorId(r.getString("MONITOR_ID"))
            .version(r.getString("VERSION"))
            .name(r.getString("NAME"))
            .country(r.getString("COUNTRY"))
            .province(r.getString("PROVINCE"))
            .city(r.getString("CITY"))
            .isp(r.getString("ISP"))
            .area(r.getString("AREA"))
            .ip(r.getString("IP"))
            .nipingT(r.getString("NIPING_T"))
            .status(status)
            .isUsable(isUsable).build();

    monitor.set(r.getString("ACCOUNT_ID"), r.getDate("CREATION_TIME"), r.getDate("MODIFIED_TIME"));
    return monitor;
}
 
開發者ID:CloudWise-OpenSource,項目名稱:SAPNetworkMonitor,代碼行數:27,代碼來源:MonitorMapper.java

示例2: testReplicationConnectionNoSlavesRemainOnMaster

import java.sql.ResultSet; //導入方法依賴的package包/類
/**
 * Test that we remain on the master when:
 * - the connection is not in read-only mode
 * - no slaves are configured
 * - a new slave is added
 */
public void testReplicationConnectionNoSlavesRemainOnMaster() throws Exception {
    Properties props = getPropertiesFromTestsuiteUrl();
    String masterHost = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY) + ":" + props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY);
    ReplicationConnection replConn = getTestReplicationConnectionNoSlaves(masterHost);
    Statement s = replConn.createStatement();
    ResultSet rs1 = s.executeQuery("select CONNECTION_ID()");
    assertTrue(rs1.next());
    int masterConnectionId = rs1.getInt(1);
    rs1.close();
    s.close();

    // add a slave and make sure we are NOT on a new connection
    replConn.addSlaveHost(masterHost);
    s = replConn.createStatement();
    rs1 = s.executeQuery("select CONNECTION_ID()");
    assertTrue(rs1.next());
    assertEquals(masterConnectionId, rs1.getInt(1));
    assertFalse(replConn.isReadOnly());
    rs1.close();
    s.close();
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:28,代碼來源:ConnectionRegressionTest.java

示例3: createPet

import java.sql.ResultSet; //導入方法依賴的package包/類
public static int createPet(int itemid, byte level, int closeness, int fullness) {
    try {
        PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("INSERT INTO pets (name, level, closeness, fullness, summoned) VALUES (?, ?, ?, ?, 0)", Statement.RETURN_GENERATED_KEYS);
        ps.setString(1, MapleItemInformationProvider.getInstance().getName(itemid));
        ps.setByte(2, level);
        ps.setInt(3, closeness);
        ps.setInt(4, fullness);
        ps.executeUpdate();
        ResultSet rs = ps.getGeneratedKeys();
        int ret = -1;
        if (rs.next()) {
            ret = rs.getInt(1);
            rs.close();
            ps.close();
        }
        return ret;
    } catch (SQLException e) {
        return -1;
    }
}
 
開發者ID:NovaStory,項目名稱:AeroStory,代碼行數:21,代碼來源:MaplePet.java

示例4: countMisfiredTriggersInState

import java.sql.ResultSet; //導入方法依賴的package包/類
/**
 * <p>
 * Get the number of triggers in the given states that have
 * misfired - according to the given timestamp.
 * </p>
 * 
 * @param conn the DB Connection
 */
public int countMisfiredTriggersInState(
        Connection conn, String state1, long ts) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(COUNT_MISFIRED_TRIGGERS_IN_STATE));
        ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
        ps.setString(2, state1);
        rs = ps.executeQuery();

        if (rs.next()) {
            return rs.getInt(1);
        }

        throw new SQLException("No misfired trigger count returned.");
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:30,代碼來源:StdJDBCDelegate.java

示例5: getDataId

import java.sql.ResultSet; //導入方法依賴的package包/類
public Integer getDataId(Connection c, String data) throws SQLException {
	if (cache.containsKey(data))
		return cache.get(data);
	
	ResultSet r = c.createStatement().executeQuery("SELECT id FROM " + tableName + " WHERE " + dataRowName + " = '" + data + "'");
	if (!r.isBeforeFirst()) {
		c.createStatement().executeUpdate("INSERT INTO " + tableName + " (" + dataRowName + ") VALUES ('" + data + "');");
		r = c.createStatement().executeQuery("SELECT id FROM " + tableName + " WHERE " + dataRowName + " = '" + data + "'");
	}
	r.next();
	
	int result = r.getInt("id");
	r.close();
	
	cache.put(data, result);
	return result;
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:18,代碼來源:DataCache.java

示例6: mapRow

import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
public User mapRow(ResultSet rs, int rowNum) throws SQLException
{
    int id = rs.getInt(USER_ID_COLUMN);
    String name = rs.getString(USER_FULL_NAME_COLUMN);
    String email = rs.getString(USER_EMAIL_COLUMN);
    String username = rs.getString(USER_NAME_COLUMN);
    Integer departmentNum = rs.getInt(USER_DEPARTMENT_NUMBER_COLUMN);
    String defaultView = rs.getString(USER_SETTING_DETAIL_DEFAULT_VIEW_COLUMN);
    String defaultWatch = rs.getString(USER_SETTING_DEFAULT_WATCH_COLUMN);

    User user = new User();
    UserSetting userSetting = new UserSetting();
    userSetting.detailDefaultView = defaultView;
    userSetting.defaultWatch = defaultWatch;
    user.id = id;
    user.name = name;
    user.email = email;
    user.userName = username;
    user.departmentNum = departmentNum;
    user.userSetting = userSetting;

    return user;
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:25,代碼來源:UserRowMapper.java

示例7: getResult

import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
public List<Weight> getResult(ResultSet resultSet) throws SQLException {
    List<Weight> result = new ArrayList<>();

    while (resultSet.next()) {

        int id = resultSet.getInt(WEIGHT_ID);
        double value = resultSet.getDouble(WEIGHT_VALUE);
        LocalDate created = convertDateToLocalDate(resultSet.getDate(WEIGHT_CREATED));
        int userId = resultSet.getInt(WEIGHT_FK_USER_ID);

        result.add(new Weight(id, value, created, userId));
    }

    return result;
}
 
開發者ID:tbressler,項目名稱:waterrower-workout,代碼行數:17,代碼來源:WeightSelect.java

示例8: loadAllies

import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
protected void loadAllies() {
    ResultSet clansResultSet = databaseConnectionOwner.executeQuery(GET_CLANS_ALLIES_QUERY);
    if (clansResultSet != null) {
        try {
            while (clansResultSet.next()) {
                int clanID = clansResultSet.getInt("clan_id");
                int clanIDAlly = clansResultSet.getInt("clan_id_ally");

                super.loadedAlly(clanID, clanIDAlly);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

}
 
開發者ID:iLefty,項目名稱:mcClans,代碼行數:18,代碼來源:DatabaseLoader.java

示例9: Announcement

import java.sql.ResultSet; //導入方法依賴的package包/類
public Announcement(ResultSet rset) throws SQLException
{
	_id = rset.getInt("id");
	_type = AnnouncementType.findById(rset.getInt("type"));
	_content = rset.getString("content");
	_author = rset.getString("author");
}
 
開發者ID:rubenswagner,項目名稱:L2J-Global,代碼行數:8,代碼來源:Announcement.java

示例10: updateClanIdColumn

import java.sql.ResultSet; //導入方法依賴的package包/類
private void updateClanIdColumn() {
    ResultSet clanResultSet = DatabaseConnectionOwner.getInstance().executeQuery(GET_CLANS_QUERY);
    if (clanResultSet != null) {
        try {
            while (clanResultSet.next()) {
                int clanId = clanResultSet.getInt("clan_id");
                UUID uuid = UUID.randomUUID();
                updateQuery("mcc_clans").value("bank_id", uuid.toString()).where("clan_id", clanId);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:iLefty,項目名稱:mcClans,代碼行數:15,代碼來源:DatabaseUpgrade2.java

示例11: itemExists

import java.sql.ResultSet; //導入方法依賴的package包/類
final private boolean itemExists(final String storeId) throws Exception {
    _itemExists.setString(1, storeId);
    ResultSet rs = _itemExists.executeQuery();
    try {
        return rs.next() && rs.getInt("N1") > 0;
    }
    finally {
        rs.close();
    }
}
 
開發者ID:neeveresearch,項目名稱:nvx-apps,代碼行數:11,代碼來源:ItemPersister.java

示例12: retreave

import java.sql.ResultSet; //導入方法依賴的package包/類
public static EntradaItem retreave(int id) throws SQLException {
    Statement stm
            = Database.createConnection().
                    createStatement();
    String sql = "SELECT * FROM entrada_itens where id = " + id;
    ResultSet rs = stm.executeQuery(sql);
    rs.next();
    return new EntradaItem(id,
            ProdutoDAO.retreave(rs.getInt("produto")),
            rs.getInt("entrada"),
            rs.getDouble("quantidade"),
            rs.getTimestamp("validade"),
            rs.getString("lote"),
            rs.getDouble("valor_unitario"));
}
 
開發者ID:Montanheiro,項目名稱:SistemaAlmoxarifado,代碼行數:16,代碼來源:EntradaItemDAO.java

示例13: getRowCount

import java.sql.ResultSet; //導入方法依賴的package包/類
public static Integer getRowCount(Datasource datasource, String schemaName, String tableName)
		throws ServiceException {

	DBType dbType = datasource.getDatabaseType();

	try (final Connection connection = ConnUtils.getNonSshConnection(datasource)) {
		String query = null;
		tableName = CommonUtils.removeQuotes(tableName);
		
		if (dbType == DBType.MYSQL || dbType == DBType.HIVE) {
			query = String.format(MYSQL_ROW_COUNT_QUERY, schemaName, tableName);
		}
		else if (dbType == DBType.POSTGRESQL || dbType == DBType.REDSHIFT 
				|| dbType == DBType.MSSQL || dbType == DBType.DERBY_LOCAL
				|| datasource.getDatabaseType() == DBType.AZURE
				|| datasource.getDatabaseType() == DBType.VERTICA) {
			query = String.format(ROW_COUNT_QUERY_WITH_SCHEMA, schemaName, tableName);
		}
		else {
			query = String.format(ROW_COUNT_QUERY, tableName);
		}

		logger.debug("Count Query = " + query);

		ResultSet rs = connection.createStatement().executeQuery(query);

		rs.next();
		return rs.getInt(1);
	}
	catch (Exception e) {
		throw new ServiceException(e);
	}
}
 
開發者ID:ajoabraham,項目名稱:hue,代碼行數:34,代碼來源:SchemaImportService.java

示例14: createGuild

import java.sql.ResultSet; //導入方法依賴的package包/類
public static int createGuild(int leaderId, String name) {
    try {
        Connection con = DatabaseConnection.getConnection();
        PreparedStatement ps = con.prepareStatement("SELECT guildid FROM guilds WHERE name = ?");
        ps.setString(1, name);
        ResultSet rs = ps.executeQuery();
        if (rs.first()) {
            ps.close();
            rs.close();
            return 0;
        }
        ps.close();
        rs.close();
        ps = con.prepareStatement("INSERT INTO guilds (`leader`, `name`, `signature`) VALUES (?, ?, ?)");
        ps.setInt(1, leaderId);
        ps.setString(2, name);
        ps.setInt(3, (int) System.currentTimeMillis());
        ps.execute();
        ps.close();
        ps = con.prepareStatement("SELECT guildid FROM guilds WHERE leader = ?");
        ps.setInt(1, leaderId);
        rs = ps.executeQuery();
        rs.first();
        int guildid = rs.getInt("guildid");
        rs.close();
        ps.close();
        return guildid;
    } catch (Exception e) {
        return 0;
    }
}
 
開發者ID:NovaStory,項目名稱:AeroStory,代碼行數:32,代碼來源:MapleGuild.java

示例15: loadOrCreateFromDB

import java.sql.ResultSet; //導入方法依賴的package包/類
public static MapleStorage loadOrCreateFromDB(int id, int world) {
    MapleStorage ret = null;
    int storeId;
    try {
        Connection con = DatabaseConnection.getConnection();
        PreparedStatement ps = con.prepareStatement("SELECT storageid, slots, meso FROM storages WHERE accountid = ? AND world = ?");
        ps.setInt(1, id);
        ps.setInt(2, world);
        ResultSet rs = ps.executeQuery();
        if (!rs.next()) {
            rs.close();
            ps.close();
            return create(id, world);
        } else {
            storeId = rs.getInt("storageid");
            ret = new MapleStorage(storeId, (byte) rs.getInt("slots"), rs.getInt("meso"));
            rs.close();
            ps.close();
            for (Pair<Item, MapleInventoryType> item : ItemFactory.STORAGE.loadItems(ret.id, false)) {
                ret.items.add(item.getLeft());
            }
        }
    } catch (SQLException ex) {
        ex.printStackTrace();
    }
    return ret;
}
 
開發者ID:NovaStory,項目名稱:AeroStory,代碼行數:28,代碼來源:MapleStorage.java


注:本文中的java.sql.ResultSet.getInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。