Пример #1
0
  public void saveSchoolClassMapDetail(SchoolClassMapVo vo) throws LmsDaoException {
    // Database connection start
    Connection conn = null;
    PreparedStatement stmt = null;
    try {

      conn = getConnection();
      String sql = "INSERT INTO school_cls_map(SCHOOL_ID, CLASS_ID)  VALUES(?, ?)";
      stmt = conn.prepareStatement(sql);
      stmt.setInt(1, vo.getSchoolId());
      stmt.setInt(2, vo.getClassId());

      // ...
      stmt.executeUpdate();
      System.out.println("Inserted 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);
    }

    System.out.println("Successfully saved....");
  }
Пример #2
0
  public boolean updateSchoolClassMapDetail(SchoolClassMapVo vo) throws LmsDaoException {
    System.out.println("id =" + vo.getSchoolId());
    boolean status = true;

    // Database connection start
    Connection conn = null;
    PreparedStatement stmt = null;
    try {

      conn = getConnection();
      String sql = "UPDATE school_cls_map set CLASS_ID=?\n" + "    WHERE SCHOOL_ID=?";
      stmt = conn.prepareStatement(sql);
      stmt.setInt(1, vo.getClassId());
      stmt.setInt(2, vo.getSchoolId());

      stmt.executeUpdate();
      System.out.println("updated records into the table...");

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

    System.out.println("Successfully updated....");
    return status;
    // End writting code to save into database
  }