MongoDB – Update to upper case

A document, and you want to update all the ‘source’ values to UPPERCASE. whois.json { “_id” : NumberLong(1), “country” : “au”, “source” : “apnic” } { “_id” : NumberLong(2), “country” : “cn”, “source” : “apnic” } { “_id” : NumberLong(3), “country” : “us”, “source” : “arin” } Solution No sure if there is any ready …

Read more

Spring Data MongoDB : Update document

In Spring data – MongoDB, you can use following methods to update documents. save – Update the whole object, if “_id” is present, perform an update, else insert it. updateFirst – Updates the first document that matches the query. updateMulti – Updates all documents that match the query. Upserting – If no document that matches …

Read more

Java MongoDB : Update document

In this tutorial, we show you how to use Java MongoDB API collection.update() to update documents. Test Data Assume following data / documents are inserted. { "hosting" : "hostA", "type" : "vps", "clients" : 1000 }, { "hosting" : "hostB", "type" : "dedicated server", "clients" : 100 }, { "hosting" : "hostC", "type" : "vps", …

Read more

Oracle Stored Procedure UPDATE example

Here’s an UPDATE stored procedure example in Oracle database. 1. Table SQL Script DBUSER table creation script. CREATE TABLE DBUSER ( USER_ID NUMBER (5) NOT NULL, USERNAME VARCHAR2 (20) NOT NULL, CREATED_BY VARCHAR2 (20) NOT NULL, CREATED_DATE DATE NOT NULL, PRIMARY KEY ( USER_ID ) ) 2. Stored Procedure A stored procedure, accept 2 IN …

Read more

JDBC PreparedStatement – Update a row

A JDBC PreparedStatement example to update a row. RowUpdate.java package com.mkyong.jdbc.preparestatement.row; import java.math.BigDecimal; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; public class RowUpdate { private static final String SQL_UPDATE = "UPDATE EMPLOYEE SET SALARY=? WHERE NAME=?"; public static void main(String[] args) { try (Connection conn = DriverManager.getConnection( "jdbc:postgresql://127.0.0.1:5432/test", "postgres", "password"); PreparedStatement preparedStatement = conn.prepareStatement(SQL_UPDATE)) …

Read more

JDBC Statement – Update a row

A JDBC Statement example to update a row. RowUpdate.java package com.mkyong.jdbc.statement.row; import java.math.BigDecimal; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class RowUpdate { public static void main(String[] args) { try (Connection conn = DriverManager.getConnection( "jdbc:postgresql://127.0.0.1:5432/test", "postgres", "password"); Statement statement = conn.createStatement()) { int row = statement.executeUpdate(updateSalaryByName("mkyong", new BigDecimal(1080))); // rows affected System.out.println(row); } …

Read more

How to update row in JSF dataTable

This example is enhancing the previous JSF 2 dataTable example, by adding a “update” function to update row in dataTable. Update Concept The overall concept is quite simple : 1. Add a “ediatble” property to keep track the row edit status. //… public class Order{ String orderNo; String productName; BigDecimal price; int qty; boolean editable; …

Read more