文档介绍:商品管理案例一:增加数据 1: Dao 代码部分// 增加商品 public boolean insert(String goodName, int num, float price) { boolean flage = true ; // 定义要执行的 sql 语句 String sql = "insert into T_goods values(?,?,?)" ; // 获得数据库连接 Connection connection = DBManager. getConnection (); try { // 定义用于发送 sql 语句到数据库执行的对象 PreparedStatement PreparedStatement pst = (sql); /// 增加商品 public boolean insert(String goodName, int num, float price) { boolean flage = true ; // 定义要执行的 sql 语句 String sql = "insert into T_goods values(?,?,?)" ; // 获得数据库连接 Connection connection = DBManager. getConnection (); try { // 定义用于发送 sql 语句到数据库执行的对象 PreparedStatement PreparedStatement pst = (sql); // 设置 pst 对象的参数 (1, goodName); (2, num); (3, price); // 将 sql 语句发送到数据库执行 (); } catch (SQLException e) { (); flage = false ; } return flage; }// 设置 pst 对象的参数 (1, goodName); (2, num); (3, price); // 将 sql 语句发送到数据库执行 (); } catch (SQLException e) { (); flage = false ; } return flage; } 2: Service 代码部分 public boolean insert(String goodName, int num, float price){ return goodsdao .insert(goodName, num, price); }3: UI 按钮事件处理事件 private void jButton1ActionPerformed( evt) { // 获取用户输入的值 int goodsId = Integer. parseInt ( jTextField1 .getText()); String goodName