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


Java ResultSet.getRow方法代码示例

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


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

示例1: initialize

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
	try {
		myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/gui_assignment?autoReconnect=true&useSSL=false", "root", "root");
		stmt = myConn.createStatement();
		
		ResultSet rs = stmt.executeQuery("select Temperature_Reading from temp_values");
		values = new int[rs.last() ? rs.getRow() : 0];
		
		int[] temp = {10000,100000,500000};
		noOfTempReadings = temp;
		
		rs.setFetchDirection(ResultSet.FETCH_REVERSE);
		rs.next();
		int i = values.length-1;
		while (rs.previous()) {
			values[i--] = rs.getInt("Temperature_Reading");
		}
	} catch (SQLException e) {
		e.printStackTrace();
		System.err.println("DATABASE CONNECT ERROR");
		System.exit(1);
	}
	
	System.out.println("No. of entries in database = "+values.length);
	
	ObservableList<String> pivotValues = FXCollections.observableArrayList("n/2","n/4","n/6");
	pivotSelect.setItems(pivotValues);
	pivotSelect.setValue("n/2");
	pivotSelect.setDisable(true);
	
	ObservableList<Integer> baseValues = FXCollections.observableArrayList(2,10,16);
	base.setItems(baseValues);
	base.setValue(10);
	base.setDisable(true);
	
	btnViewGraph.setDisable(true);
}
 
开发者ID:kevalmorabia97,项目名称:GUI-Sorting-Time-Comparison-using-JavaFx,代码行数:39,代码来源:MainController.java

示例2: ensureTableContent

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 *  ensures the content of a given table matches a given object array's content
 */
private void ensureTableContent(String tableName,
                                Object[][] tableData) throws SQLException {

    ResultSet lhs = m_statement.executeQuery("SELECT * FROM \""
        + tableName + "\"");
    ResultSetMetaData meta     = lhs.getMetaData();
    int               colCount = meta.getColumnCount();

    while (lhs.next()) {
        int row = lhs.getRow();

        assertEquals(colCount, tableData[row - 1].length);

        for (int col = 1; col <= colCount; ++col) {
            assertEquals(
                "unexpected table content in " + tableName + " (row "
                + row + ", col " + col + ")", tableData[row - 1][col - 1],
                                              lhs.getObject(col));
        }
    }
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:25,代码来源:TestViewAsterisks.java

示例3: getAppDefultRank

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public List<App> getAppDefultRank(final int typeId, final int top) {
    PreparedStatementCallback<List<App>> cb = new PreparedStatementCallback<List<App>>() {
        @Override
        public List<App> doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
            ps.setInt(1, typeId);
            ps.setInt(2, top);
            ResultSet rs = null;
            try {
                rs = ps.executeQuery();
                if (rs.last()) {
                    int count = rs.getRow();
                    List<App> list = new ArrayList<App>(count);
                    rs.beforeFirst();
                    App app = null;
                    while (rs.next()) {
                        app = appRowMapper.mapRow(rs, rs.getRow());
                        changeOutputImpl.setUrls(app);
                        list.add(app);
                    }
                    return list;
                }

            } catch (Exception e) {
                logger.error("SQL data error:", e);
                return null;
            } finally {
                if (null != rs)
                    rs.close();
            }
            return null;
        }
    };
    return jdbcTemplate.execute(QUERY_APP_DEFAULT_TOP_SQL, cb);
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:36,代码来源:AppRankDaoImpl.java

示例4: doQuery

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public ResultSet doQuery(final SqlContext sqlContext, final PreparedStatement preparedStatement,
		final ResultSet resultSet) {
	// カウント初期値
	int rowCount = -1;
	try {
		// resultSetのカーソル種別を取得
		// 種別「TYPE_FORWARD_ONLY」の場合、beforeFirstメソッドが効かないため除外
		if (resultSet.getType() != ResultSet.TYPE_FORWARD_ONLY) {
			// 件数結果取得
			resultSet.last();
			rowCount = resultSet.getRow();
			resultSet.beforeFirst();
		}
	} catch (SQLException e) {
		// ここでの例外は実処理に影響を及ぼさないよう握りつぶす
	}

	String userName = getParam(sqlContext, USER_NAME_KEY);
	if (userName == null) {
		// ユーザ名が設定されていない時
		userName = DEFAULT_USER_NAME;
	}

	String funcId = getParam(sqlContext, FUNC_ID_KEY);
	if (funcId == null) {
		// 機能IDが設定されていない時
		funcId = DEFAULT_FUNC_ID;
	}

	LOG.debug(ToStringBuilder.reflectionToString(
			new AuditData(userName, funcId, sqlContext.getSqlId(), sqlContext.getSqlName(), sqlContext
					.getExecutableSql(), rowCount), ToStringStyle.JSON_STYLE));

	return resultSet;
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:37,代码来源:AuditLogSqlFilter.java

示例5: BBSThreadList

import java.sql.ResultSet; //导入方法依赖的package包/类
public static byte[] BBSThreadList(ResultSet rs, int start) throws SQLException {
    final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
    mplew.writeShort(SendOpcode.GUILD_BBS_PACKET.getValue());
    mplew.write(0x06);
    if (!rs.last()) {
        mplew.write(0);
        mplew.writeInt(0);
        mplew.writeInt(0);
        return mplew.getPacket();
    }
    int threadCount = rs.getRow();
    if (rs.getInt("localthreadid") == 0) { //has a notice
        mplew.write(1);
        addThread(mplew, rs);
        threadCount--; //one thread didn't count (because it's a notice)
    } else {
        mplew.write(0);
    }
    if (!rs.absolute(start + 1)) { //seek to the thread before where we start
        rs.first(); //uh, we're trying to start at a place past possible
        start = 0;
    }
    mplew.writeInt(threadCount);
    mplew.writeInt(Math.min(10, threadCount - start));
    for (int i = 0; i < Math.min(10, threadCount - start); i++) {
        addThread(mplew, rs);
        rs.next();
    }
    return mplew.getPacket();
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:31,代码来源:MaplePacketCreator.java

示例6: getUserName

import java.sql.ResultSet; //导入方法依赖的package包/类
public static String[] getUserName(String mailId) {
    String[] name={"",""};

    Connection con = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;

    String query = DBUtils.prepareSelectQuery(" * ",
            "classroomflipkart.userdetail",
            " emailId = '"+mailId+"' ",
            "" );

    try {
        con = DBUtils.getConnection();
        stmt = con.prepareStatement(query);
        rs = stmt.executeQuery();

        rs.last();
        int size = rs.getRow();

        if (size>0){
            rs.beforeFirst();
            rs.next();
            name[0] = rs.getString("name");
            name[1] = rs.getString("certifiedUser");
        }
        else
            name[0] = "";

    } catch (Exception e) {
        name[0] = e.getMessage();
        e.printStackTrace();
    } finally {
        DBUtils.closeAll(rs, stmt, con);
        return name;
    }
}
 
开发者ID:madHEYsia,项目名称:ClassroomFlipkart,代码行数:38,代码来源:getUserName.java

示例7: getCategories

import java.sql.ResultSet; //导入方法依赖的package包/类
public static String[] getCategories() {
    String[] category = {"ongoing"};

    Connection con = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;

    String query = DBUtils.prepareSelectQuery(" * ",
            "classroomflipkart.category",
            "",
            "GROUP BY category");

    try {
        con = DBUtils.getConnection();
        stmt = con.prepareStatement(query);
        rs = stmt.executeQuery();

        rs.last();
        int size = rs.getRow();

        if (size>0){
            rs.beforeFirst();

            int count = 0;
            category = new String[size];

            while (rs.next())
                category[count++] = rs.getString("category");
        }

    } catch (Exception e) {
        category[0] = e.getMessage();
        e.printStackTrace();
    } finally {
        DBUtils.closeAll(rs, stmt, con);
        return category;
    }
}
 
开发者ID:madHEYsia,项目名称:ClassroomFlipkart,代码行数:39,代码来源:getCategories.java

示例8: isFavoriteExistes

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * 
 * @param serverIp
 * @param userServerId
 * @param userId
 * @return
 */
public Boolean isFavoriteExistes(String serverIp, String userServerId, String userId) {
	Connection conn = JdbcHelper.getJdbcHelper().getConnection();
	PreparedStatement ps = null;
	ResultSet rs = null;
	
	try {
		if(null != conn) {
			String sql = "select m.* from myfavorites m where m.USERID=? and m.USERSERVERID=? and m.SERVERIP=?;";
			ps = conn.prepareStatement(sql);
			ps.setString(1, userId);
			ps.setString(2, userServerId);
			ps.setString(3, serverIp);
			
			rs = ps.executeQuery();
			
			if(null == rs)
				return null;
			rs.last();
			System.out.println(rs.getRow());
			if(0 < rs.getRow())
				return true;
			return false;
		}
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		System.out.println("sql state: " + e.getSQLState() +
				" --> " + e.getStackTrace() + "  -->" + e.getMessage());
		return null;
	}
	return null;
}
 
开发者ID:UnicornWebbChen,项目名称:GameProject-V1.0Beta,代码行数:39,代码来源:MyFavoriteDao.java

示例9: getAppCategoryRank

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public List<App> getAppCategoryRank(final int parentId, final int subCatalog, final int top) {
    PreparedStatementCallback<List<App>> cb = new PreparedStatementCallback<List<App>>() {
        @Override
        public List<App> doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
            ps.setInt(1, parentId);
            ps.setInt(2, subCatalog);
            ps.setInt(3, top);
            ResultSet rs = null;
            try {
                rs = ps.executeQuery();
                if (rs.last()) {
                    int count = rs.getRow();
                    List<App> list = new ArrayList<App>(count);
                    rs.beforeFirst();
                    App app = null;
                    while (rs.next()) {
                        app = appRowMapper.mapRow(rs, rs.getRow());
                        changeOutputImpl.setUrls(app);
                        list.add(app);
                    }
                    return list;
                }

            } catch (Exception e) {
                logger.error("SQL data error:", e);
                return null;
            } finally {
                if (null != rs)
                    rs.close();
            }
            return null;
        }
    };
    return jdbcTemplate.execute(QUERY_APP_CATEGORY_TOP_SQL, cb);
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:37,代码来源:AppRankDaoImpl.java

示例10: findByIds

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public List<App> findByIds(List<Integer> ids) {
    // Session session = sessions.getCurrentSession();
    // Query query = null;
    // query =
    // session.createQuery("select a.id, a.name, a.downLoadLink, a.logo from App a where id in (:ids)").setParameterList("ids",
    // ids);
    // List<App> list = HibernateHelper.list(query);
    // for (App app : list) {
    // changeOutputImpl.setUrls(app);
    // }
    StringBuilder tmp = new StringBuilder(ids.size() * 6);
    for (Integer id : ids) {
        tmp.append(id).append(',');
    }
    tmp.deleteCharAt(tmp.length() - 1);
    String sql = appsByIds.replace("?", tmp.toString());

    PreparedStatementCallback<List<App>> cb = new PreparedStatementCallback<List<App>>() {
        @Override
        public List<App> doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
            ResultSet rs = null;
            try {
                rs = ps.executeQuery();
                if (rs.last()) {
                    int count = rs.getRow();
                    List<App> list = new ArrayList<App>(count);
                    rs.beforeFirst();
                    App app = null;
                    while (rs.next()) {
                        app = appsRowMapper.mapRow(rs, rs.getRow());
                        changeOutputImpl.setUrls(app);
                        list.add(app);
                    }
                    return list;
                } else {
                    return null;
                }
            } finally {
                if (null != rs) {
                    rs.close();
                }
            }
        }

    };
    return this.jdbcTemplate.execute(sql, cb);
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:49,代码来源:AppsDaoImpl.java

示例11: databaseSchemasCoincide

import java.sql.ResultSet; //导入方法依赖的package包/类
private boolean databaseSchemasCoincide() {
	
	try {
		// For each DBMS table
		tablesResultSet.beforeFirst();
		while (tablesResultSet.next()) {
			// Getting tables
			String tableName = tablesResultSet.getString("TABLE_NAME");
			Table currentLocalTable = getDatabase().getTableByName(tableName);
			int numberOfAttributesForRemote = 0;
			
			if (currentLocalTable != null) {
			
				// Getting attributes
				ResultSet attrResultSet = databaseMetadata.getColumns(null, null, tableName, "%");
				
				// Getting the number of rows returned (number of attributes in the current table)
				// and storing it in the 'numberOfAttributesForRemote'
				if (attrResultSet != null) {  
				  attrResultSet.beforeFirst();  
				  attrResultSet.last();  
				  numberOfAttributesForRemote = attrResultSet.getRow();
				  attrResultSet.beforeFirst();
				}
				
				// If the number of attributes differs, databases are not compatibles
				if (currentLocalTable.getNumOfColumns() != numberOfAttributesForRemote) {
					return false;
				}
				
				// COMPARING ATTRIBUTES
				while (attrResultSet.next()) {
					String attrName = attrResultSet.getString("COLUMN_NAME");
					String attrType = attrResultSet.getString("TYPE_NAME");
					DataType attrDataType;
					
					// Comparing data types
					if (attrType.contains("varchar")) {
						attrDataType = DataType.STRING;
					} else if (attrType.contains("char")) {
						attrDataType = DataType.CHAR;
					} else if (attrType.contains("int")) {
						attrDataType = DataType.INT;
					} else if (attrType.contains("float")) {
						attrDataType = DataType.FLOAT;
					} else if (attrType.contains("date")) {
						attrDataType = DataType.DATE;
					} else {
						attrDataType = null;
					}
					
					// Check if the attribute exists on the current table
					if (!currentLocalTable.attributeExists(attrName, attrDataType)) {
						return false;
					}
				}
			}
		}
		
		tablesResultSet.isBeforeFirst();
	}
	
	catch (SQLException e) {
		e.printStackTrace();
	}
		
	return true;
}
 
开发者ID:tteguayco,项目名称:JITRAX,代码行数:69,代码来源:DatabaseComparator.java

示例12: tableExists

import java.sql.ResultSet; //导入方法依赖的package包/类
public static boolean tableExists(SQLConnection connection, String table) throws ClassNotFoundException, SQLException {
    checkAndOpen(connection);
    Connection c = connection.getConnection();
    DatabaseMetaData metaData = c.getMetaData();
    ResultSet rs = metaData.getTables(null, null, table, null);
    if (rs.next()) {
        return rs.getRow() == 1;
    }
    return false;
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:11,代码来源:SQLUtil.java

示例13: getRow

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public int getRow() throws SQLException {
    int currentRow = this.getCurrentResultSet() == null ? 0 : this.getCurrentResultSet().getRow();
    int totalRowsOfPreviousResultSets = 0;
    if (currentIndex - 2 >= 0) {
        int index = currentIndex - 2;
        for (; index >= 0; index--) {
            ResultSet set = results.get(index).getResultSet();
            set.last();
            totalRowsOfPreviousResultSets += set.getRow();
        }
    }
    return currentRow + totalRowsOfPreviousResultSets;
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:15,代码来源:MultiShardResultSet.java

示例14: DatabaseDataRow

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * Creates a data row from the given result set. The current row of the result set if used as
 * data source.
 */
public DatabaseDataRow(ResultSet resultSet) throws SQLException {
	this.resultSet = resultSet;
	this.row = resultSet.getRow();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:9,代码来源:DatabaseDataRow.java

示例15: checkSorting

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * checks sorting a table with according to a given collation
 */
protected String checkSorting(String collationName) {

    String stmt1 = "DROP TABLE WORDLIST IF EXISTS;";
    String stmt2 =
        "CREATE TEXT TABLE WORDLIST ( ID INTEGER, WORD VARCHAR(50) );";
    String stmt3 = "SET TABLE WORDLIST SOURCE \"" + collationName
                   + ".csv;encoding=UTF-8\"";
    String selectStmt    = "SELECT ID, WORD FROM WORDLIST ORDER BY WORD";
    String returnMessage = "";

    try {

        // set database collation
        statement.execute(getSetCollationStmt(collationName));
        statement.execute(stmt1);
        statement.execute(stmt2);
        statement.execute(stmt3);

        ResultSet results = statement.executeQuery(selectStmt);

        while (results.next()) {
            int expectedPosition = results.getInt(1);
            int foundPosition    = results.getRow();

            if (expectedPosition != foundPosition) {
                String word = results.getString(2);

                return "testing collation '" + collationName
                       + "' failed\n" + "  word              : " + word
                       + "\n" + "  expected position : "
                       + expectedPosition + "\n"
                       + "  found position    : " + foundPosition + "\n";
            }
        }
    } catch (SQLException e) {
        return "testing collation '" + collationName
               + "' failed\n  exception message: " + e.getMessage() + "\n";
    }

    return "";
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:45,代码来源:TestCollation.java


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