Biblioteca Java - Blame information for rev 14

Subversion Repositories:
Rev:
Rev Author Line No. Line
14 mihai 1 package hm.spring.web.dao;
2  
3 import hm.spring.web.domain.Student;
4  
5 import java.util.List;
6  
7 import javax.sql.DataSource;
8  
9 import org.springframework.jdbc.core.JdbcTemplate;
10 import org.springframework.stereotype.Repository;
11  
12 @Repository
13 public class StudentJDBCTemplate implements StudentDAO {
14    private DataSource dataSource;
15    private JdbcTemplate jdbcTemplateObject;
16  
17    public void setDataSource(DataSource dataSource) {
18       this.dataSource = dataSource;
19       this.jdbcTemplateObject = new JdbcTemplate(dataSource);
20    }
21  
22    public void create(String name, Integer age) {
23       String SQL = "insert into Student (name, age) values (?, ?)";
24  
25       jdbcTemplateObject.update( SQL, name, age);
26       System.out.println("Created Record Name = " + name + " Age = " + age);
27       return;
28    }
29  
30    public Student getStudent(Integer id) {
31       String SQL = "select * from Student where id = ?";
32       Student student = jdbcTemplateObject.queryForObject(SQL,
33                         new Object[]{id}, new StudentMapper());
34       return student;
35    }
36  
37    public List<Student> listStudents() {
38       String SQL = "select * from Student";
39       List <Student> students = jdbcTemplateObject.query(SQL,
40                                 new StudentMapper());
41       return students;
42    }
43  
44    public void delete(Integer id){
45       String SQL = "delete from Student where id = ?";
46       jdbcTemplateObject.update(SQL, id);
47       System.out.println("Deleted Record with ID = " + id );
48       return;
49    }
50  
51    public void update(Integer id, Integer age){
52       String SQL = "update Student set age = ? where id = ?";
53       jdbcTemplateObject.update(SQL, age, id);
54       System.out.println("Updated Record with ID = " + id );
55       return;
56    }
57  
58 }