package bazy.podstawy;

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ProsteZapytanie2 {
	public static void main(String[] args) {
		try(Connection c = DriverManager.getConnection("jdbc:postgresql://localhost/hr", "kurs", "abc123");
			PreparedStatement stmt = c.prepareStatement("SELECT * FROM employees");
			ResultSet rs = stmt.executeQuery()) {
			
			while(rs.next()) {
				int id = rs.getInt(1);
				String imie = rs.getString("first_name");
				String nazwisko = rs.getString("last_name");
				String job = rs.getString("job_id");
				BigDecimal pensja = rs.getBigDecimal("salary");
				java.sql.Date data = rs.getDate("hire_date");
				System.out.printf("%d. %s %s (%s) zatr. %s zarabia %s\n", id, imie, nazwisko, job, data, pensja);
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

}
