Exemplo n.º 1
0
  public List<SchoolClassMapVo> getSchoolClassMapVoList() throws LmsDaoException {
    List<SchoolClassMapVo> distList = new ArrayList<SchoolClassMapVo>();

    // 1 . jdbc code start
    Connection conn = null;
    PreparedStatement stmt = null;
    try {
      conn = getConnection();

      String sql = "SELECT * FROM school_cls_map ";
      stmt = conn.prepareStatement(sql);
      ResultSet rs = stmt.executeQuery();
      while (rs.next()) {

        // 3. Set db data to object
        SchoolClassMapVo userDtls = new SchoolClassMapVo();
        userDtls.setSchoolId(rs.getInt("SCHOOL_ID"));
        userDtls.setClassId(rs.getInt("CLASS_ID"));

        // Add into list
        distList.add(userDtls);
      }

      System.out.println("get records into the table...");

    } catch (SQLException se) {
      System.out.println("getSchoolClassMapDetail # " + se);
      se.printStackTrace();
    } catch (Exception e) {
      System.out.println("getSchoolClassMapDetail # " + e);
      e.printStackTrace();
    } finally {
      closeResources(conn, stmt, null);
    }
    // 1 . jdbc code endd

    // 4 Return as required by method
    return distList;
  }
Exemplo n.º 2
0
  public SchoolClassMapVo getSchoolClassMapDetail(int id) throws LmsDaoException {
    System.out.println("Inside getSchoolClassMapDetail(?) >>");
    // Create object to return
    SchoolClassMapVo userDtls = new SchoolClassMapVo();

    // 1 . jdbc code start
    Connection conn = null;
    PreparedStatement stmt = null;
    try {
      conn = getConnection();

      String sql = "SELECT * FROM school_cls_map where SCHOOL_ID=?";
      stmt = conn.prepareStatement(sql);
      stmt.setInt(1, userDtls.getSchoolId());
      ResultSet rs = stmt.executeQuery();
      if (rs.next()) {
        // 3. Set db data to object

        userDtls.setSchoolId(rs.getInt("SCHOOL_ID"));
        userDtls.setClassId(rs.getInt("CLASS_ID"));
      }

      System.out.println("get records into the table...");

    } catch (SQLException se) {
      System.out.println("getSchoolClassMapDetail # " + se);
      se.printStackTrace();
    } catch (Exception e) {
      System.out.println("getSchoolClassMapDetail # " + e);
      e.printStackTrace();
    } finally {
      closeResources(conn, stmt, null);
    }
    // 1 . jdbc code endd

    // 4 Return as required by method
    return userDtls;
  }