Ejemplo n.º 1
0
 public Category find(String id) {
   try {
     Connection conn = JdbcUtils.getConnection();
     QueryRunner runner = new QueryRunner();
     String sql = "select * from category where id=?";
     return (Category) runner.query(conn, sql, id, new BeanHandler(Category.class));
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Ejemplo n.º 2
0
 public List getAll() {
   try {
     Connection conn = JdbcUtils.getConnection();
     QueryRunner runner = new QueryRunner();
     String sql = "select * from category";
     return (List) runner.query(conn, sql, new BeanListHandler(Category.class));
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Ejemplo n.º 3
0
  public void add(Category c) {

    try {
      Connection conn = JdbcUtils.getConnection();
      QueryRunner runner = new QueryRunner();
      String sql = "insert into category(id,name,description) values(?,?,?)";
      Object params[] = {c.getId(), c.getName(), c.getDescription()};
      runner.update(conn, sql, params);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }