Java Code Examples for java.sql.ResultSet#updateDouble()
The following examples show how to use
java.sql.ResultSet#updateDouble() .
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 | 6 votes |
/** * Tests calling updateDouble on all columns of the row. * @exception SQLException database access error. Causes test to * fail with an error. */ public void testUpdateDouble() 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.updateDouble(i, 2.0); assertEquals("Expected rs.getDouble(" + i + ") to match updated value", 2, (int) rs.getDouble(i)); } rs.updateRow(); rs.close(); checkColumnsAreUpdated(); s.close(); }
Example 2
Source File: UpdateXXXTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Tests calling updateDouble on all columns of the row. * @exception SQLException database access error. Causes test to * fail with an error. */ public void testUpdateDouble() 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.updateDouble(i, 2.0); assertEquals("Expected rs.getDouble(" + i + ") to match updated value", 2, (int) rs.getDouble(i)); } rs.updateRow(); rs.close(); checkColumnsAreUpdated(); s.close(); }
Example 3
Source File: UpdateXXXTest.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
/** * Tests calling updateDouble on all columns of the row. * @exception SQLException database access error. Causes test to * fail with an error. */ public void testUpdateDouble() 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.updateDouble(i, 2.0); assertEquals("Expected rs.getDouble(" + i + ") to match updated value", 2, (int) rs.getDouble(i)); } rs.updateRow(); rs.close(); checkColumnsAreUpdated(); s.close(); }
Example 4
Source File: ParameterMappingTest.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
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 5
Source File: RoutinesDefinersRightsTest.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
/** * Test that PHB can actually update using {@code ResultSet.insertRow}, * {@code ResultSet.updateRow} and {@code ResultSet.deleteRow}. * <p/> * Aside: This test is somewhat artificial here, since the middle manager * would not be allowed to do this, presumably; just added here to test * this functionality (which was initially broken by the first patch for * DERBY-4551). * <p/> * The problem was that the nested statement contexts used for SQL * substatements generated for these ResultSet operations were not * correctly set up, so the effective user id would not be the DEFINER * (DBO), and authorization would fail. Cf DERBY-4551 and DERBY-3327 * for more detail. */ public static void updateWage() throws SQLException { Connection c = null; c = DriverManager.getConnection("jdbc:default:connection"); Statement cStmt = c.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); // Try nested statements by inserting, updating and deleting a bogus // row ResultSet rs = cStmt.executeQuery( "select * from s1.wages"); assertTrue(rs.isBeforeFirst()); rs.moveToInsertRow(); rs.updateInt("EMPLOYEEID", 666); rs.updateInt("CATEGORY", 667); rs.updateDouble("SALARY", 666.0); rs.updateString("NAME", "N.N."); rs.insertRow(); rs.close(); rs = cStmt.executeQuery( "select * from s1.wages where name = 'N.N.'"); rs.next(); rs.updateDouble("SALARY", 666.1); rs.updateRow(); rs.close(); rs = cStmt.executeQuery( "select * from s1.wages where name = 'N.N.'"); rs.next(); rs.deleteRow(); rs.close(); cStmt.close(); c.close(); }
Example 6
Source File: UnsupportedUpdateOperationResultSetTest.java From sharding-jdbc-1.5.1 with Apache License 2.0 | 4 votes |
@Test(expected = SQLFeatureNotSupportedException.class) public void assertUpdateDoubleForColumnIndex() throws SQLException { for (ResultSet each : resultSets) { each.updateDouble(1, 1D); } }
Example 7
Source File: UnsupportedUpdateOperationResultSetTest.java From sharding-jdbc-1.5.1 with Apache License 2.0 | 4 votes |
@Test(expected = SQLFeatureNotSupportedException.class) public void assertUpdateDoubleForColumnLabel() throws SQLException { for (ResultSet each : resultSets) { each.updateDouble("label", 1D); } }
Example 8
Source File: UnsupportedUpdateOperationResultSetTest.java From shardingsphere with Apache License 2.0 | 4 votes |
@Test(expected = SQLFeatureNotSupportedException.class) public void assertUpdateDoubleForColumnIndex() throws SQLException { for (ResultSet each : resultSets) { each.updateDouble(1, 1D); } }
Example 9
Source File: UnsupportedUpdateOperationResultSetTest.java From shardingsphere with Apache License 2.0 | 4 votes |
@Test(expected = SQLFeatureNotSupportedException.class) public void assertUpdateDoubleForColumnLabel() throws SQLException { for (ResultSet each : resultSets) { each.updateDouble("label", 1D); } }
Example 10
Source File: JdbcLiveTest.java From tutorials with MIT License | 4 votes |
@Test public void whenInsertUpdateRecord_thenCorrect() throws SQLException { Statement stmt = con.createStatement(); String insertSql = "INSERT INTO employees(name, position, salary) values ('john', 'developer', 2000)"; stmt.executeUpdate(insertSql); String selectSql = "SELECT * FROM employees"; ResultSet resultSet = stmt.executeQuery(selectSql); List<Employee> employees = new ArrayList<>(); while (resultSet.next()) { Employee emp = new Employee(); emp.setId(resultSet.getInt("emp_id")); emp.setName(resultSet.getString("name")); emp.setSalary(resultSet.getDouble("salary")); emp.setPosition(resultSet.getString("position")); employees.add(emp); } assertEquals("employees list size incorrect", 1, employees.size()); assertEquals("name incorrect", "john", employees.iterator().next().getName()); assertEquals("position incorrect", "developer", employees.iterator().next().getPosition()); assertEquals("salary incorrect", 2000, employees.iterator().next().getSalary(), 0.1); Statement updatableStmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet updatableResultSet = updatableStmt.executeQuery(selectSql); updatableResultSet.moveToInsertRow(); updatableResultSet.updateString("name", "mark"); updatableResultSet.updateString("position", "analyst"); updatableResultSet.updateDouble("salary", 2000); updatableResultSet.insertRow(); String updatePositionSql = "UPDATE employees SET position=? WHERE emp_id=?"; PreparedStatement pstmt = con.prepareStatement(updatePositionSql); pstmt.setString(1, "lead developer"); pstmt.setInt(2, 1); String updateSalarySql = "UPDATE employees SET salary=? WHERE emp_id=?"; PreparedStatement pstmt2 = con.prepareStatement(updateSalarySql); pstmt.setDouble(1, 3000); pstmt.setInt(2, 1); boolean autoCommit = con.getAutoCommit(); try { con.setAutoCommit(false); pstmt.executeUpdate(); pstmt2.executeUpdate(); con.commit(); } catch (SQLException exc) { con.rollback(); } finally { con.setAutoCommit(autoCommit); } }
Example 11
Source File: SQLDouble.java From gemfirexd-oss with Apache License 2.0 | votes |
/** 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.updateDouble(position, value); }
Example 12
Source File: SQLDouble.java From gemfirexd-oss with Apache License 2.0 | votes |
/** 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.updateDouble(position, value); }
Example 13
Source File: SQLDouble.java From spliceengine with GNU Affero General Public License v3.0 | votes |
/** 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.updateDouble(position, value); }