Java Code Examples for java.sql.ResultSet#updateFloat()

The following examples show how to use java.sql.ResultSet#updateFloat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateXXXTest.java    From gemfirexd-oss with Apache License 2.0 7 votes vote down vote up
/**
 * Tests calling updateFloat on all columns of the row.
 * @exception SQLException database access error. Causes test to 
 *                         fail with an error.
 */
public void testUpdateFloat() 
    throws SQLException
{
    Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY, 
            ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = s.executeQuery(SELECT_STMT);
    rs.next();

    for (int i = 1; i <= COLUMNS; i++) {
        rs.updateFloat(i, 2.0f);
        assertEquals("Expected rs.getFloat(" + i + 
                     ") to match updated value", 2, (int) rs.getFloat(i));
    }
    rs.updateRow();
    rs.close();
    checkColumnsAreUpdated();
    
    s.close();
}
 
Example 2
Source File: ExportToJdbcPlugin.java    From constellation with Apache License 2.0 6 votes vote down vote up
private static void updateResultSetParam(final GraphReadMethods rg, final ResultSet rs, final String label, final Attribute attr, final int id) throws SQLException {
    switch (attr.getAttributeType()) {
        case "boolean":
            rs.updateBoolean(label, rg.getBooleanValue(attr.getId(), id));
            break;
        case "date":
            final long date = rg.getLongValue(attr.getId(), id);
            if (date != Long.MIN_VALUE) {
                rs.updateDate(label, new Date(date));
            }
            break;
        case "datetime":
            final long timestamp = rg.getLongValue(attr.getId(), id);
            if (timestamp != Long.MIN_VALUE) {
                rs.updateTimestamp(label, new Timestamp(timestamp));
            }
            break;
        case "integer":
            rs.updateInt(label, rg.getIntValue(attr.getId(), id));
            break;
        case "float":
            rs.updateFloat(label, rg.getFloatValue(attr.getId(), id));
            break;
        case "time":
            final long time = rg.getLongValue(attr.getId(), id);
            if (time != Long.MIN_VALUE) {
                rs.updateTime(label, new Time(time));
            }
            break;
        default:
            final String s = rg.getStringValue(attr.getId(), id);
            if (s != null) {
                rs.updateString(label, s);
            }
            break;
    }
}
 
Example 3
Source File: UpdateXXXTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Tests calling updateFloat on all columns of the row.
 * @exception SQLException database access error. Causes test to 
 *                         fail with an error.
 */
public void testUpdateFloat() 
    throws SQLException
{
    Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY, 
            ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = s.executeQuery(SELECT_STMT);
    rs.next();

    for (int i = 1; i <= COLUMNS; i++) {
        rs.updateFloat(i, 2.0f);
        assertEquals("Expected rs.getFloat(" + i + 
                     ") to match updated value", 2, (int) rs.getFloat(i));
    }
    rs.updateRow();
    rs.close();
    checkColumnsAreUpdated();
    
    s.close();
}
 
Example 4
Source File: UpdateXXXTest.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Tests calling updateFloat on all columns of the row.
 * @exception SQLException database access error. Causes test to 
 *                         fail with an error.
 */
public void testUpdateFloat() 
    throws SQLException
{
    Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY, 
            ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = s.executeQuery(SELECT_STMT);
    rs.next();

    for (int i = 1; i <= COLUMNS; i++) {
        rs.updateFloat(i, 2.0f);
        assertEquals("Expected rs.getFloat(" + i + 
                     ") to match updated value", 2, (int) rs.getFloat(i));
    }
    rs.updateRow();
    rs.close();
    checkColumnsAreUpdated();
    
    s.close();
}
 
Example 5
Source File: ParameterMappingTest.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
private void assertUpdateState(
    ResultSet rs,
    String colName,
    long value,
    double dvalue,
    int updateType,
    String expected) throws SQLException {

    try {
        switch (updateType) {
        case XXX_BYTE:
            rs.updateByte(colName, (byte)value);
            break;
        case XXX_SHORT:
            rs.updateShort(colName, (short)value);
        case XXX_INT:
            rs.updateInt(colName, (int)value);
            break;
        case XXX_LONG:
            rs.updateLong(colName, value);
            break;
        case XXX_FLOAT:
            rs.updateFloat(colName, (float)dvalue);
            break;
        case XXX_DOUBLE:
            rs.updateDouble(colName, dvalue);
            break;
        default:
            fail("wrong argument");
        }

        fail("exception expected");
    } catch (SQLException e) {
        println(e.toString());
        assertSQLState(expected, e);
    }
}
 
Example 6
Source File: UnsupportedUpdateOperationResultSetTest.java    From sharding-jdbc-1.5.1 with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateFloatForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateFloat(1, 1F);
    }
}
 
Example 7
Source File: UnsupportedUpdateOperationResultSetTest.java    From sharding-jdbc-1.5.1 with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateFloatForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateFloat("label", 1F);
    }
}
 
Example 8
Source File: UnsupportedUpdateOperationResultSetTest.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateFloatForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateFloat(1, 1F);
    }
}
 
Example 9
Source File: UnsupportedUpdateOperationResultSetTest.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateFloatForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateFloat("label", 1F);
    }
}
 
Example 10
Source File: SQLReal.java    From gemfirexd-oss with Apache License 2.0 votes vote down vote up
/**
	Set this value into a ResultSet for a subsequent ResultSet.insertRow
	or ResultSet.updateRow. This method will only be called for non-null values.

	@exception SQLException thrown by the ResultSet object
	@exception StandardException thrown by me accessing my value.
*/
public final void setInto(ResultSet rs, int position) throws SQLException, StandardException {
	rs.updateFloat(position, value);
}
 
Example 11
Source File: SQLReal.java    From gemfirexd-oss with Apache License 2.0 votes vote down vote up
/**
	Set this value into a ResultSet for a subsequent ResultSet.insertRow
	or ResultSet.updateRow. This method will only be called for non-null values.

	@exception SQLException thrown by the ResultSet object
	@exception StandardException thrown by me accessing my value.
*/
public final void setInto(ResultSet rs, int position) throws SQLException, StandardException {
	rs.updateFloat(position, value);
}
 
Example 12
Source File: SQLReal.java    From spliceengine with GNU Affero General Public License v3.0 votes vote down vote up
/**
	Set this value into a ResultSet for a subsequent ResultSet.insertRow
	or ResultSet.updateRow. This method will only be called for non-null values.

	@exception SQLException thrown by the ResultSet object
	@exception StandardException thrown by me accessing my value.
*/
public final void setInto(ResultSet rs, int position) throws SQLException, StandardException {
	rs.updateFloat(position, value);
}