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

The following are Jave code examples for showing how to use isLast() 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: OperatieBRP   File: GenerateEnumerationsMojo.java   View Source Code Vote up 6 votes
@Override
protected void processRecord(final StringBuilder result, final ResultSet resultSet) throws SQLException {
    final String javaDoc = resultSet.getString(1);
    final String javaNameBase = resultSet.getString(2);
    final String javaStatement = resultSet.getString(3);

    // Javadoc
    result.append(INDENTATION).append("/** ").append(javaDoc).append(" */\n");

    // Statement
    result.append(INDENTATION).append(Utils.convertToJavaEnumName(javaNameBase)).append(javaStatement);

    // Seperator
    if (resultSet.isLast()) {
        result.append(";\n");
    } else {
        result.append(",\n");
    }
}
 
Example 2
Project: HTAPBench   File: ClientBalancer.java   View Source Code Vote up 5 votes
/**
 * Computes the current TPM count by issuing a SQL statement to the database.
 * @throws SQLException 
 */
private void getTPS_statement() throws SQLException{
    //PostGreSQL
    ResultSet rs = executeSQLStmt("select xact_commit from pg_stat_database");
    while (rs.next()) {
        int currentTPS = rs.getInt(1);
        if(rs.isLast()){
            currentTPS = rs.getInt(1);
            this.TPM = (currentTPS - previous_TPS);
            previous_TPS = currentTPS;
        }     
    }
}
 
Example 3
Project: open-rmbt   File: OpenTestResource.java   View Source Code Vote up 4 votes
/**
 * Gets all signal measurements from a test
 *
 * @param testUID  the test uid
 * @param testTime the begin of the test
 * @throws SQLException
 */
public SignalGraph(long testUID, UUID openTestUuid, long testTime, java.sql.Connection conn) throws SQLException {
    PreparedStatement psSignal = conn.prepareStatement("SELECT test_id, nt.name network_type, nt.group_name cat_technology, signal_strength, lte_rsrp, lte_rsrq, wifi_rssi, time "
            + "FROM signal "
            + "JOIN network_type nt "
            + "ON nt.uid = network_type_id "
            + "WHERE test_id = ? "
            + "ORDER BY time;");
    psSignal.setLong(1, testUID);

    ResultSet rsSignal = psSignal.executeQuery();

    //if there are no results -> try using the new radio-tables that may be available for some measurements
    if (!rsSignal.isBeforeFirst()) {
        psSignal = conn.prepareStatement("SELECT radio_cell.open_test_uuid, nt.name network_type, technology cat_technology, signal_strength, lte_rsrp, lte_rsrq, signal_strength wifi_rssi, time " +
                "FROM radio_cell " +
                "JOIN radio_signal ON radio_signal.cell_uuid = radio_cell.uuid " +
                "JOIN network_type nt ON nt.uid = network_type_id " +
                "WHERE radio_cell.open_test_uuid = ? " +
                "AND radio_cell.active = TRUE " +
                "  ORDER BY radio_signal.time;");
        psSignal.setObject(1, openTestUuid);

        rsSignal = psSignal.executeQuery();
    }

    boolean first = true;
    SignalGraphItem item = null;
    while (rsSignal.next()) {
        long timeElapsed = rsSignal.getTimestamp("time").getTime() - testTime;
        //there could be measurements taken before a test started
        //in this case, only return the last one
        if (first && timeElapsed > 0 && item != null) {
            this.signalList.add(item);
            first = false;
        }

        //ignore measurements after a threshold of one minute
        if (timeElapsed > MAX_TIME)
            break;


        int signalStrength = rsSignal.getInt("signal_strength");
        int lteRsrp = rsSignal.getInt("lte_rsrp");
        int lteRsrq = rsSignal.getInt("lte_rsrq");
        if (signalStrength == 0)
            signalStrength = rsSignal.getInt("wifi_rssi");

        if (signalStrength > LOWER_BOUND)
            item = new SignalGraphItem(Math.max(timeElapsed, 0), rsSignal.getString("network_type"), signalStrength, lteRsrp, lteRsrq, rsSignal.getString("cat_technology"));


        //put 5-let in the array if it is not the first one
        if (!first || rsSignal.isLast()) {
            if (timeElapsed < 0) {
                item.timeElapsed = 1000;
            }
            this.signalList.add(item);
        }
    }

    rsSignal.close();
    psSignal.close();
}
 
Example 4
Project: open-rmbt   File: OpenTestResource.java   View Source Code Vote up 4 votes
/**
 * Gets all signal measurements from a test
 * @param testUID the test uid
 * @param testTime the begin of the test
 * @throws SQLException
 */
public SignalGraph(long testUID, long testTime, java.sql.Connection conn) throws SQLException {
	PreparedStatement psSignal = conn.prepareStatement("SELECT test_id, nt.name network_type, nt.group_name cat_technology, signal_strength, lte_rsrp, lte_rsrq, wifi_rssi, time "
       		+ "FROM signal "
       		+ "JOIN network_type nt "
       		+ "ON nt.uid = network_type_id "
       		+ "WHERE test_id = ? "
       		+ "ORDER BY time;");
       psSignal.setLong(1, testUID);
       
       ResultSet rsSignal = psSignal.executeQuery();
       
       boolean first = true;
       SignalGraphItem item = null;
       while (rsSignal.next()) {
       	long timeElapsed = rsSignal.getTimestamp("time").getTime() - testTime;
       	//there could be measurements taken before a test started
       	//in this case, only return the last one
       	if (first && timeElapsed > 0 && item != null) {
       		this.signalList.add(item);
       		first = false;
       	}
       	
       	//ignore measurements after a threshold of one minute
       	if (timeElapsed > MAX_TIME) 
       		break;
       	
       	
       	int signalStrength = rsSignal.getInt("signal_strength");
       	int lteRsrp = rsSignal.getInt("lte_rsrp");
       	int lteRsrq = rsSignal.getInt("lte_rsrq");
       	if (signalStrength == 0)
       		signalStrength = rsSignal.getInt("wifi_rssi");
       	
       	if (signalStrength > LOWER_BOUND)
       		item = new SignalGraphItem(Math.max(timeElapsed,0), rsSignal.getString("network_type"), signalStrength, lteRsrp, lteRsrq, rsSignal.getString("cat_technology"));
       	
       	
       	//put 5-let in the array if it is not the first one
       	if (!first || rsSignal.isLast()) {
       		if (timeElapsed < 0) {
       			item.timeElapsed = 1000;
       		}
       		this.signalList.add(item);
       	}
       }
       
       rsSignal.close();
       psSignal.close();
}
 
Example 5
Project: open-rmbt   File: OpenTestResource.java   View Source Code Vote up 4 votes
/**
 * Gets all signal measurements from a test
 * @param testUID the test uid
 * @param testTime the begin of the test
 * @throws SQLException
 */
   public SignalGraph(long testUID, UUID openTestUuid, long testTime, java.sql.Connection conn) throws SQLException {
	PreparedStatement psSignal = conn.prepareStatement("SELECT test_id, nt.name network_type, nt.group_name cat_technology, signal_strength, lte_rsrp, lte_rsrq, wifi_rssi, time "
       		+ "FROM signal "
       		+ "JOIN network_type nt "
       		+ "ON nt.uid = network_type_id "
       		+ "WHERE test_id = ? "
       		+ "ORDER BY time;");
       psSignal.setLong(1, testUID);

       ResultSet rsSignal = psSignal.executeQuery();

       //if there are no results -> try using the new radio-tables that may be available for some measurements
       if (!rsSignal.isBeforeFirst()) {
           psSignal = conn.prepareStatement("SELECT radio_cell.open_test_uuid, nt.name network_type, technology cat_technology, signal_strength, lte_rsrp, lte_rsrq, signal_strength wifi_rssi, time " +
                   "FROM radio_cell " +
                   "JOIN radio_signal ON radio_signal.cell_uuid = radio_cell.uuid " +
                   "JOIN network_type nt ON nt.uid = network_type_id " +
                   "WHERE radio_cell.open_test_uuid = ? " +
                   "AND radio_cell.active = TRUE " +
                   "  ORDER BY radio_signal.time;");
           psSignal.setObject(1, openTestUuid);

           rsSignal = psSignal.executeQuery();
       }

       boolean first = true;
       SignalGraphItem item = null;
       while (rsSignal.next()) {
       	long timeElapsed = rsSignal.getTimestamp("time").getTime() - testTime;
       	//there could be measurements taken before a test started
       	//in this case, only return the last one
       	if (first && timeElapsed > 0 && item != null) {
       		this.signalList.add(item);
       		first = false;
       	}

       	//ignore measurements after a threshold of one minute
       	if (timeElapsed > MAX_TIME)
       		break;


       	int signalStrength = rsSignal.getInt("signal_strength");
       	int lteRsrp = rsSignal.getInt("lte_rsrp");
       	int lteRsrq = rsSignal.getInt("lte_rsrq");
       	if (signalStrength == 0)
       		signalStrength = rsSignal.getInt("wifi_rssi");

       	if (signalStrength > LOWER_BOUND)
       		item = new SignalGraphItem(Math.max(timeElapsed,0), rsSignal.getString("network_type"), signalStrength, lteRsrp, lteRsrq, rsSignal.getString("cat_technology"));


       	//put 5-let in the array if it is not the first one
       	if (!first || rsSignal.isLast()) {
       		if (timeElapsed < 0) {
       			item.timeElapsed = 1000;
       		}
       		this.signalList.add(item);
       	}
       }

       rsSignal.close();
       psSignal.close();
}