Statement s = connect.createStatement();
String sql = "UPDATE customer " + "SET BUDGET = '5000000' " + " WHERE CUSTOMERID = 'C005' ";
s.execute(sql);
package com.java.myapp; import java.sql.SQLException; import java.sql.Statement; import java.sql.Connection; import java.sql.DriverManager; public class MyClass { public static void main(String[] args) { Connection connect = null; Statement s = null; try { Class.forName("oracle.jdbc.driver.OracleDriver"); connect = DriverManager.getConnection("" + "jdbc:oracle:thin:@TCDB", "myuser","mypassword"); s = connect.createStatement(); String sql = "UPDATE customer " + "SET BUDGET = '5000000' " + " WHERE CUSTOMERID = 'C005' "; s.execute(sql); System.out.println("Record Update Successfully"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } try { s.close(); connect.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท