1
2
3
4
5
6
7 package org.mule.test.integration.transaction.extras;
8
9 import java.sql.Types;
10
11 import org.springframework.jdbc.core.JdbcTemplate;
12
13 public class JdbcLibraryDao implements LibraryDao
14 {
15
16 private JdbcTemplate jdbcTemplate;
17
18 public void setJdbcTemplate(JdbcTemplate jdbcTemplate)
19 {
20 this.jdbcTemplate = jdbcTemplate;
21 }
22
23 public boolean insertBook(Book book) throws Exception
24 {
25 String sql = "insert into book (id, title, author) values (?,?,?)";
26 Object args[] = new Object[] {new Integer(book.getSerialNo()), book.getTitle(), book.getAuthor()};
27 int types[] = new int[] {Types.INTEGER, Types.VARCHAR, Types.VARCHAR};
28 try
29 {
30 jdbcTemplate.update(sql, args, types);
31 return true;
32 }
33 catch (Exception e)
34 {
35 System.out.println(e.getMessage());
36 throw e;
37
38 }
39 }
40 }