package com.javahonk;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.javahonk.dao.IPersonDAO;
import com.javahonk.di.bean.Person;

public class TestSpringJDBCTemplate {

    public static void main(String[] args) throws Exception {
	
	ClassPathXmlApplicationContext applicationContext = 
		new ClassPathXmlApplicationContext(
			"spring\\application-config.xml");

	IPersonDAO personDAO = applicationContext.
		getBean("personDAO", IPersonDAO.class);
	Person person = new Person("Java", "Honk", 
		"John st.","NY", "NY", "USA");
	
	//Insert user to the table 3 times:
	for (int i = 0; i < 3; i++) {
	    personDAO.insertUser(person); 
	}
	
	//Delete first person from table
	personDAO.deletePerson(1);
		
	//Select all inserted user from the table
	personDAO.selectAllPerson();	
	
	//Select data from tabel where person 
	//name is "Java"
	personDAO.selectPersonByName();
	

	applicationContext.close();

    }

}
