Package com.apress.prospring.ch8.spring

Examples of com.apress.prospring.ch8.spring.JdbcAbstractTestDao


    try {
      connection = getConnection();
      PreparedStatement statement = connection.prepareStatement("select * from Test");
      ResultSet resultSet = statement.executeQuery();
      while (resultSet.next()) {
        Test test = new Test();
        test.setName(resultSet.getString("Name"));
        test.setTestId(resultSet.getInt("TestId"));
        result.add(test);
      }
    } catch (SQLException ex) {
      ex.printStackTrace();
    } finally {
View Full Code Here


        private int testId = -1;
       
        public Object doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
          List result = new ArrayList();
          int lastTestId = -1;
          Test test = null;
          ResultSet rs = ps.executeQuery();
          while (rs.next()) {
            testId = rs.getInt("TestId");
            if (testId != lastTestId) {
              test = new Test();
              test.setTestId(testId);
              test.setName(rs.getString("Name"));
              test.setDetails(new ArrayList());
            }
            TestDetail td = new TestDetail();
            td.setData(rs.getString("Data"));
            td.setTest(rs.getInt("Test"));
            td.setTestDetailId(rs.getInt("TestDetailId"));
            test.getDetails().add(td);
          }
          return result;
        }
     
      });
View Full Code Here

    public AbstractSelect(DataSource dataSource, String sql) {
      super(dataSource, sql);
    }

    protected Object mapRow(ResultSet rs, int rowNum) throws SQLException {
      Test test = new Test();

      test.setName(rs.getString("Name"));
      test.setTestId(rs.getInt("TestId"));

      return test;
    }
View Full Code Here

              test = new Test();
              test.setTestId(testId);
              test.setName(rs.getString("Name"));
              test.setDetails(new ArrayList());
            }
            TestDetail td = new TestDetail();
            td.setData(rs.getString("Data"));
            td.setTest(rs.getInt("Test"));
            td.setTestDetailId(rs.getInt("TestDetailId"));
            test.getDetails().add(td);
          }
          return result;
        }
     
View Full Code Here

  /**
   * Main code
   */
  private void run() {
    TestDao testDao = new PlainTestDao();
   
    List l = testDao.getAll();
    for (Iterator i = l.iterator(); i.hasNext();) {
      System.out.println(i.next());
    }
  }
View Full Code Here

TOP

Related Classes of com.apress.prospring.ch8.spring.JdbcAbstractTestDao

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.