// 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.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import com.packt.pfblueprints.model.JobPosts;
package com.packt.pfblueprints.dao;




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(
// 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/dao/JobPostsDAO.java
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import com.packt.pfblueprints.model.JobPosts;

package com.packt.pfblueprints.dao;




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");