zoukankan      html  css  js  c++  java
  • CShop Project : 进行单个商品信息的查询

    public Goods getById(int id) throws SQLException {
    QueryRunner r = new QueryRunner(DBUtil.getDataSource());
    String sql = "select g.id,g.name,g.cover,g.image1,g.image2,g.price,g.intro,g.stock,t.id typeid,t.name typename from goods g,type t where g.id = ? and g.type_id=t.id";
    return r.query(sql, new BeanHandler<Goods>(Goods.class),id);
    }

    public static void main(String[] args) throws SQLException {
    Goods g = new GoodsDao().getById(3);
    System.out.println(g);
    }

    // Output

    Goods [id=3, name=留恋之恋, cover=/picture/3-1.jpg, image1=/picture/3-2.jpg, image2=/picture/3-3.jpg, price=229.0, intro=主口味:榴莲奶油味(原味蛋糕胚+榴莲酱+乳脂奶油)主要原料:新西兰乳脂奶油,古巴朗姆酒,韩国幼砂糖,鲜草莓。 甜度: 三星(满五星) 最佳食用温度:5-7摄氏度, stock=10, type=com.Jasper2003.model.Type@2752f6e2]

  • 相关阅读:
    九度oj题目1019:简单计算器
    九度oj题目1555:重复子串
    Java泛型
    Remove Duplicates from Sorted Array
    Add Binary
    Plus One
    Remove Element
    Remove Nth Node From End of List
    Longest Common Prefix
    Roman to Integer
  • 原文地址:https://www.cnblogs.com/JasperZhao/p/13613759.html
Copyright © 2011-2022 走看看