// Path: chapter02/src/main/java/com/packt/pfblueprints/dao/JobPostsDAO.java
// public class JobPostsDAO {
// 	private DataSource ds;
// 	Connection con; 
// 
// 
// 	public JobPostsDAO() throws SQLException {
// 		try {
// 			Context ctx = new InitialContext();
// 			ds = (DataSource) ctx.lookup("java:comp/env/jdbc/blueprintsdb");
// 			if (ds == null)
// 				throw new SQLException("Can't get data source");
// 
// 			// get database connection
// 			con = ds.getConnection();
// 
// 			if (con == null)
// 				throw new SQLException("Can't get database connection");
// 
// 		} catch (NamingException e) {
// 			e.printStackTrace();
// 		}
// 
// 	}
// 	public List<JobPosts> getAllJobs() throws SQLException{
// 		PreparedStatement ps 
// 		= con.prepareStatement(
// 		   "select company,domain,experience,position,location from blueprintsdb.jobposts");
// 		
// 		//get jobposts data from database
// 				ResultSet result =  ps.executeQuery();
// 
// 		List<JobPosts> list = new ArrayList<JobPosts>();
// 		 
// 		while(result.next()){
// 			JobPosts post = new JobPosts();
//  
// 			post.setCompany(result.getString("company"));
// 			post.setDomain(result.getString("domain"));
// 			post.setExperience(result.getString("experience"));
// 			post.setPosition(result.getString("position"));
// 			post.setLocation(result.getString("location"));
//  
// 			list.add(post);
// 		}
//  
// 		return list;
// 		
// 	}
// 	
// }
// 
// Path: chapter02/src/main/java/com/packt/pfblueprints/model/JobPosts.java
// public class JobPosts {
// 	
// 	private String company;
// 	private String domain;
// 	private String experience;
// 	private String position;
// 	private String location;
// 	
// 	
// 	
// 	public String getCompany() {
// 		return company;
// 	}
// 	public void setCompany(String company) {
// 		this.company = company;
// 	}
// 	public String getDomain() {
// 		return domain;
// 	}
// 	public void setDomain(String domain) {
// 		this.domain = domain;
// 	}
// 	public String getExperience() {
// 		return experience;
// 	}
// 	public void setExperience(String experience) {
// 		this.experience = experience;
// 	}
// 	public String getPosition() {
// 		return position;
// 	}
// 	public void setPosition(String position) {
// 		this.position = position;
// 	}
// 	public String getLocation() {
// 		return location;
// 	}
// 	public void setLocation(String location) {
// 		this.location = location;
// 	}
// 	
// 	
// 
// }


import java.io.Serializable;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import com.packt.pfblueprints.dao.JobPostsDAO;
import com.packt.pfblueprints.model.JobPosts;
package com.packt.pfblueprints.controller;




@ManagedBean
@ViewScoped
public class JobPostsController implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	List<JobPosts> jobslist=new ArrayList<JobPosts>();
	
	@SuppressWarnings("restriction")
	@PostConstruct  
	public void init() { 
		JobPostsDAO dao;
		try {
// Path: chapter02/src/main/java/com/packt/pfblueprints/dao/JobPostsDAO.java
// public class JobPostsDAO {
// 	private DataSource ds;
// 	Connection con; 
// 
// 
// 	public JobPostsDAO() throws SQLException {
// 		try {
// 			Context ctx = new InitialContext();
// 			ds = (DataSource) ctx.lookup("java:comp/env/jdbc/blueprintsdb");
// 			if (ds == null)
// 				throw new SQLException("Can't get data source");
// 
// 			// get database connection
// 			con = ds.getConnection();
// 
// 			if (con == null)
// 				throw new SQLException("Can't get database connection");
// 
// 		} catch (NamingException e) {
// 			e.printStackTrace();
// 		}
// 
// 	}
// 	public List<JobPosts> getAllJobs() throws SQLException{
// 		PreparedStatement ps 
// 		= con.prepareStatement(
// 		   "select company,domain,experience,position,location from blueprintsdb.jobposts");
// 		
// 		//get jobposts data from database
// 				ResultSet result =  ps.executeQuery();
// 
// 		List<JobPosts> list = new ArrayList<JobPosts>();
// 		 
// 		while(result.next()){
// 			JobPosts post = new JobPosts();
//  
// 			post.setCompany(result.getString("company"));
// 			post.setDomain(result.getString("domain"));
// 			post.setExperience(result.getString("experience"));
// 			post.setPosition(result.getString("position"));
// 			post.setLocation(result.getString("location"));
//  
// 			list.add(post);
// 		}
//  
// 		return list;
// 		
// 	}
// 	
// }
// 
// Path: chapter02/src/main/java/com/packt/pfblueprints/model/JobPosts.java
// public class JobPosts {
// 	
// 	private String company;
// 	private String domain;
// 	private String experience;
// 	private String position;
// 	private String location;
// 	
// 	
// 	
// 	public String getCompany() {
// 		return company;
// 	}
// 	public void setCompany(String company) {
// 		this.company = company;
// 	}
// 	public String getDomain() {
// 		return domain;
// 	}
// 	public void setDomain(String domain) {
// 		this.domain = domain;
// 	}
// 	public String getExperience() {
// 		return experience;
// 	}
// 	public void setExperience(String experience) {
// 		this.experience = experience;
// 	}
// 	public String getPosition() {
// 		return position;
// 	}
// 	public void setPosition(String position) {
// 		this.position = position;
// 	}
// 	public String getLocation() {
// 		return location;
// 	}
// 	public void setLocation(String location) {
// 		this.location = location;
// 	}
// 	
// 	
// 
// }


// Path: chapter02/src/main/java/com/packt/pfblueprints/controller/JobPostsController.java
import java.io.Serializable;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import com.packt.pfblueprints.dao.JobPostsDAO;
import com.packt.pfblueprints.model.JobPosts;

package com.packt.pfblueprints.controller;




@ManagedBean
@ViewScoped
public class JobPostsController implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	List<JobPosts> jobslist=new ArrayList<JobPosts>();
	
	@SuppressWarnings("restriction")
	@PostConstruct  
	public void init() { 
		JobPostsDAO dao;
		try {
			dao = new JobPostsDAO();