当前位置: 首页>>代码示例>>Java>>正文


Java ResultSet.next方法代码示例

本文整理汇总了Java中java.sql.ResultSet.next方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.next方法的具体用法?Java ResultSet.next怎么用?Java ResultSet.next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.ResultSet的用法示例。


在下文中一共展示了ResultSet.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findHeroesById

import java.sql.ResultSet; //导入方法依赖的package包/类
public Hero findHeroesById(String term) throws SQLException {

		String query = "SELECT h.id, h.name, h.sex, i.name AS real_name, m.name AS movies_name, t.team_name AS team_name, h.picture, h.abilities, h.history, t.picture "
				+ "FROM heroes h LEFT JOIN movie_hero mh ON h.id = mh.id_hero "
				+ "LEFT JOIN movie m ON mh.id_movie = m.id " + "LEFT JOIN team_hero th ON th.hero_id = h.id "
				+ "LEFT JOIN team t ON t.team_id = th.team_id " + "LEFT JOIN irl i ON i.hero_id = h.id "
				+ "WHERE h.id='"+term +"'";

		Connection connect = connectToMySQL();
		Statement statement = connect.createStatement();
		ResultSet resultSet = statement.executeQuery(query);
		if (resultSet.next()){
			Hero hero = resultSetToHero(resultSet);
			connect.close();
			return hero;
		}
		else{
			connect.close();
			return null;
		}


	}
 
开发者ID:Bartac,项目名称:avengers-db,代码行数:24,代码来源:HeroDAO.java

示例2: retreaveByEntrada

import java.sql.ResultSet; //导入方法依赖的package包/类
public static ArrayList<EntradaItem> retreaveByEntrada(int entradaId) throws SQLException {
    Statement stm
            = Database.createConnection().
                    createStatement();
    String sql = "SELECT * FROM entrada_itens where entrada = " + entradaId;
    ResultSet rs = stm.executeQuery(sql);
    ArrayList<EntradaItem> entrada = new ArrayList<>();
    while (rs.next()) {
        entrada.add(new EntradaItem(
                rs.getInt("id"),
                ProdutoDAO.retreave(rs.getInt("produto")),
                rs.getInt("entrada"),
                rs.getDouble("quantidade"),
                rs.getTimestamp("validade"),
                rs.getString("lote"),
                rs.getDouble("valor_unitario")));
    }
    rs.next();
    return entrada;
}
 
开发者ID:Montanheiro,项目名称:SistemaAlmoxarifado,代码行数:21,代码来源:EntradaItemDAO.java

示例3: getTemplateConfig

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * 获得Template配置文件信息
 * 
 * @return
 * @throws Exception
 */
public static TemplateConfig getTemplateConfig(String name) throws Exception {
	Connection conn = null;
	Statement stat = null;
	ResultSet rs = null;
	try {
		conn = getConnection();
		stat = conn.createStatement();
		String sql = String.format("select * from TemplateConfig where name='%s'", name);
		ResultSet resultSet = stat.executeQuery(sql);
		while (resultSet.next()) {
			TemplateConfig result = JSON.parseObject(resultSet.getString("value"), TemplateConfig.class);
			return result;
		}
	} finally {
		if (rs != null)
			rs.close();
		if (stat != null)
			stat.close();
		if (conn != null)
			conn.close();
	}
	return null;
}
 
开发者ID:shenzhenMirren,项目名称:vertx-generator,代码行数:30,代码来源:ConfigUtil.java

示例4: getOneProduct

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * 从数据库查询结果中获取product
 * @param rs 查询结果集
 * @return 返回查询到的产品,否则返回null
 */
private Product getOneProduct(ResultSet rs) {
    Product product = null;
    try {
        if(rs.next()) {
            product = new Product();
            product.setProductId(rs.getInt("pid"));
            product.setProductName(rs.getString("pname"));
            product.setProductPrice(rs.getInt("pprice"));
            product.setNumber(rs.getInt("pnumber"));
            product.setProductTime(rs.getTime("producttime"));
            product.setId(rs.getInt("id"));
            ProductType productType = productTypeDao.queryProductTypeByTypeId(rs.getInt("ptype"));
            product.setProductType(productType);
            product.setFileName(rs.getString("filename"));
        }
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        super.closeAll();
    }
    return product;
}
 
开发者ID:aimkiray,项目名称:sgroup,代码行数:28,代码来源:ProductDaoImpl.java

示例5: getInstanceList

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * 封装实体
 * 
 * @param cls
 *            实体类
 * @param list
 *            数据查询结果集
 * @return
 */
public static final <E> List<E> getInstanceList(Class<E> cls, ResultSet rs) {
	List<E> resultList = newArrayList();
	try {
		E object = cls.newInstance();
		Field[] fields = cls.getDeclaredFields();
		while (rs.next()) {
			object = cls.newInstance();
			for (int i = 0; i < fields.length; i++) {
				String fieldName = fields[i].getName();
				PropertyUtils.setProperty(object, fieldName, rs.getObject(fieldName));
			}
			resultList.add(object);
		}
	} catch (Exception e) {
		throw new InstanceException(e);
	}
	return resultList;
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:28,代码来源:InstanceUtil.java

示例6: getValue

import java.sql.ResultSet; //导入方法依赖的package包/类
public DefaultComboBoxModel getValue(){
    DefaultComboBoxModel modelo = new DefaultComboBoxModel();
    modelo.addElement("Selecciona Proyecto");
    String sql_select;
    sql_select="SELECT nombre_proyecto FROM  proyectos";// Where nombre_equipo LIKE '" + indi + "%'";
   
     try{
        Connection conn= fachada.getConnetion();
        System.out.println("consultando en la bd");
        Statement sentencia = conn.createStatement();
        ResultSet tabla = sentencia.executeQuery(sql_select);
        while(tabla.next()){
            modelo.addElement(tabla.getString(1));
        }
        tabla.close();
        sentencia.close();
      
     }
     catch(Exception e){ System.out.println(e);}
     return modelo;     
}
 
开发者ID:franco026,项目名称:LOSY,代码行数:22,代码来源:DaoProyect.java

示例7: checkNameAndPwd

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public boolean checkNameAndPwd(String name, String password)
{
	try
	{
		ResultSet rs = con.query("select * from users where u_name=? and u_pwd=? ",
				new String[] { name,password});
		if(rs.next())
			return true;
		else
			return false;
	}
	catch (Exception e)
	{
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:sxei,项目名称:myqq,代码行数:19,代码来源:UserDao.java

示例8: getColumnRemarks

import java.sql.ResultSet; //导入方法依赖的package包/类
private String getColumnRemarks(String tableName,String columnName,DatabaseMetaData databaseMetaData) throws SQLException{
	String remarks=null;
	ResultSet rs=null;
	try{
		rs=databaseMetaData.getColumns(null, null, tableName,"%");
		while(rs.next()){
			String colName=rs.getString("COLUMN_NAME");
			if(columnName.equals(colName)){
				remarks=rs.getString("REMARKS");
				break;
			}
		}
	}finally{
		if(rs!=null)rs.close();
	}
	return remarks;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:18,代码来源:EntityPR.java

示例9: getPandoraLog

import java.sql.ResultSet; //导入方法依赖的package包/类
public int getPandoraLog(String itemid) {
Connection con1 = DatabaseConnection.getConnection();
try {
int ret_count = 0;
PreparedStatement ps;
ps = con1.prepareStatement("select count(*) from pandoralog where characterid = ? and itemid = ? and lastattempt >= subtime(current_timestamp, '1 0:0:0.0')");
ps.setInt(1, id);
ps.setString(2, itemid);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
ret_count = rs.getInt(1);
} else {
ret_count = -1;
}
rs.close();
ps.close();
return ret_count;
} catch (Exception Ex) {
	System.out.print("Error reading Pandora Log.");
return -1;
}
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:23,代码来源:MapleCharacter.java

示例10: getUnavailableNumbers

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public List<Integer> getUnavailableNumbers(UUID driverid, String classcode)
{
    List<Integer> ret = new ArrayList<Integer>();
    try
    {
        boolean superunique = Integer.parseInt(getSetting("superuniquenumbers")) != 0;
        ResultSet rs;

        if (superunique) {
            rs = executeSelect("select distinct number from cars where number not in (select number from cars where driverid=?)", newList(driverid));
        } else {
            rs = executeSelect("select distinct number from cars where classcode=? and number not in (select number from cars where classcode=? and driverid=?)", newList(classcode, classcode, driverid));
        }

        while (rs.next())
            ret.add(rs.getInt(1));
    }
    catch (Exception e)
    {
        logError("getUnavailableNumbers", e);
    }

    return ret;
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:26,代码来源:SQLDataInterface.java

示例11: displayAllUsers

import java.sql.ResultSet; //导入方法依赖的package包/类
public void displayAllUsers() throws SQLException {

		ResultSet result = null;

		ps = conn
				.prepareStatement("select * from test.users");
		result = ps.executeQuery();

		int i = 0;
		while (result.next()) {
			System.out.println(++i + " -> " + result.getString(1) + " "
					+ result.getString(2) + " " + result.getString(3));
		}

		System.out.println("Select SQL executed successfully ");
	}
 
开发者ID:Illusionist80,项目名称:SpringTutorial,代码行数:17,代码来源:MySQLUserDAO.java

示例12: getHeight

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * Get block position in blockchain
 *
 * @param db data connection
 * @param id block id
 * @return block height or -1 if block not exist
 * @throws DataAccessException problems with the DB
 */
public static int getHeight(ConnectionProxy db, final long id) {
	try {

		PreparedStatement statement = db.prepareStatement("SELECT \"height\" FROM \"block\" where \"id\" = ?");
		int h = -1;
		synchronized (statement) {

			statement.setLong(1, id);

			ResultSet set = statement.executeQuery();
			while (set.next()) {
				h = set.getInt(1);
			}
			set.close();

		}

		return h;

	} catch (Exception e) {
		throw new DataAccessException(e);
	}
}
 
开发者ID:EonTechnology,项目名称:server,代码行数:32,代码来源:BlockHelper.java

示例13: performQuery

import java.sql.ResultSet; //导入方法依赖的package包/类
@NonNull
protected ResultSet performQuery(MariaDBContainer containerRule, String sql) throws SQLException {
    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setJdbcUrl(containerRule.getJdbcUrl());
    hikariConfig.setUsername(containerRule.getUsername());
    hikariConfig.setPassword(containerRule.getPassword());

    HikariDataSource ds = new HikariDataSource(hikariConfig);
    Statement statement = ds.getConnection().createStatement();
    statement.execute(sql);
    ResultSet resultSet = statement.getResultSet();

    resultSet.next();
    return resultSet;
}
 
开发者ID:testcontainers,项目名称:testcontainers-java-module-mariadb,代码行数:16,代码来源:SimpleMariaDBTest.java

示例14: getRowCount

import java.sql.ResultSet; //导入方法依赖的package包/类
protected int getRowCount(String tableName) throws SQLException {
    ResultSet countRs = null;

    try {
        countRs = this.stmt.executeQuery("SELECT COUNT(*) FROM " + tableName);

        countRs.next();

        return countRs.getInt(1);
    } finally {
        if (countRs != null) {
            countRs.close();
        }
    }
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:16,代码来源:BaseTestCase.java

示例15: testClobberStreamingRS

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * Tests that streaming result sets are registered correctly.
 * 
 * @throws Exception
 *             if any errors occur
 */
public void testClobberStreamingRS() throws Exception {
    try {
        Properties props = new Properties();
        props.setProperty("clobberStreamingResults", "true");

        Connection clobberConn = getConnectionWithProps(props);

        Statement clobberStmt = clobberConn.createStatement();

        clobberStmt.executeUpdate("DROP TABLE IF EXISTS StreamingClobber");
        clobberStmt.executeUpdate("CREATE TABLE StreamingClobber ( DUMMYID INTEGER NOT NULL, DUMMYNAME VARCHAR(32),PRIMARY KEY (DUMMYID) )");
        clobberStmt.executeUpdate("INSERT INTO StreamingClobber (DUMMYID, DUMMYNAME) VALUES (0, NULL)");
        clobberStmt.executeUpdate("INSERT INTO StreamingClobber (DUMMYID, DUMMYNAME) VALUES (1, 'nro 1')");
        clobberStmt.executeUpdate("INSERT INTO StreamingClobber (DUMMYID, DUMMYNAME) VALUES (2, 'nro 2')");
        clobberStmt.executeUpdate("INSERT INTO StreamingClobber (DUMMYID, DUMMYNAME) VALUES (3, 'nro 3')");

        Statement streamStmt = null;

        try {
            streamStmt = clobberConn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
            streamStmt.setFetchSize(Integer.MIN_VALUE);

            this.rs = streamStmt.executeQuery("SELECT DUMMYID, DUMMYNAME FROM StreamingClobber ORDER BY DUMMYID");

            this.rs.next();

            // This should proceed normally, after the driver clears the input stream
            ResultSet rs2 = clobberStmt.executeQuery("SHOW VARIABLES");
            rs2.next();
            this.rs.close();
        } finally {
            if (streamStmt != null) {
                streamStmt.close();
            }
        }
    } finally {
        this.stmt.executeUpdate("DROP TABLE IF EXISTS StreamingClobber");
    }
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:46,代码来源:ResultSetRegressionTest.java


注:本文中的java.sql.ResultSet.next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。