package dbtest;

import java.beans.Statement;
import java.sql.Connection;
import java.sql.ResultSet;

public class Dao {
	Employee e = null;
	String s;
	Connection con = (Connection) new Connects().connect();
	public Employee fetchOnId(int id) {  // this will return an employer object e with attribute from database.
		try {  // what does the statement object do???
			Statement statement = (Statement) con.createStatement();  // statement from connector
			// ID is always 12???
			ResultSet rs = ((java.sql.Statement) statement).executeQuery("select * from employee where id=12");
			System.out.println(con);
			while(rs.next()) {
				e = new Employee();
				e.age = rs.getInt(1);
				e.name = rs.getString(2);
				e.salary = rs.getInt(3);
			}
			con.close();
		} catch(Exception e) {
			System.out.println(e);
		}
		return e;
	}
}
