Code example for PreparedStatement

Methods: setDate, setLong, setString

0
				.update( 
						"insert into book_tbl (title, isbn_number, authors, " 
								+ "created_date, created_by) values(?, ?, ?, ?, ?)", 
								new PreparedStatementSetter() { 
									public void setValues(PreparedStatement ps) throws SQLException {
										ps.setString(1, book.getName());
										ps.setLong(2, book.getIsbnNumber());
										ps.setString(3, book.getAuthor());
										ps.setDate(4, new java.sql.Date(book.getCreatedDate().getTime()));
										ps.setString(5, book.getCreatedBy());
									} 
								} 
					); 
	} 
 
	public Book getBook(Long id) {
		List<Book> books = this.jdbcTemplate.query(
				"select * from book_tbl where book_id = ?", new Object[] { id },
				new BookMapper()); 
		Book book = DataAccessUtils.singleResult(books);
		return book;