docs.intersystems.com
MultiValue Quick Start Tutorial
JDBC Update
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Search:    

The following code executes an SQL UPDATE on a row of the MVFILE.PERSON table. In detail, the code does the following:

  1. Creates a connection to Caché using java.sql.Connection.
  2. Creates a java.sql.PreparedStatement object and uses it to execute the UPDATE.
  3. Closes the database connection.
//Create the connection
Class.forName("com.intersys.jdbc.CacheDriver");
String url="jdbc:Cache://localhost:1972/MyAccount";
Connection conn = DriverManager.getConnection(url);
           
//created the prepared statement  
String sql = "UPDATE MVFILE.PERSON (AGE,PHONE) VALUES" +
            " ('45','111-111-1111,222-222-2222') WHERE NAME='IDLE,JIM'";
PreparedStatement pstmt = conn.prepareStatement(sql);
        
//execute the update
int status = pstmt.executeUpdate();
System.out.printf("Status %s",status);
           
 conn.close();       
Note:
The above code is contained in RunUpdate.java. This file is in <cachesys>\Dev\tutorials\mv. Executing the Java Examples contains step-by-step instructions for executing this code.


Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA