当前位置: 首页>>代码示例>>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;未经允许,请勿转载。