setprice.java

来自「此程序都是企业级 的数据库开发程序 全面揭示了JAVA对数据库的操作」· Java 代码 · 共 34 行

JAVA
34
字号
package procedures;

import java.sql.*;
import connections.*;
import java.util.*;

public class SetPrice {
  public static void main(String[] args) {
    Connection conn = null;
    CallableStatement stmt = null;

    try {
      conn = ConnectionFactory.getConnection();

      String sql = "{ call set_price(?, ?) }";
      stmt = conn.prepareCall(sql);
      stmt.setInt(1, Integer.parseInt(args[0]));
      stmt.setDouble(2, Double.parseDouble(args[1]));

      stmt.executeUpdate();

      // if no exception is thrown, the update succeeded
      System.out.println("SetPrice succeeded");
    } catch (Exception e) {
      System.out.println("SetPrice failed");
      e.printStackTrace();
    } 
    finally {
      ConnectionFactory.close(stmt);
      ConnectionFactory.close(conn);
    } 
  } 
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?