package biblioteki;

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 Sqlite2 {

	public static void main(String[] args) {
		try(Connection c = DriverManager.getConnection("jdbc:sqlite:hr.db");
			PreparedStatement stmt = c.prepareStatement("SELECT * FROM employees");
			ResultSet rs = stmt.executeQuery()) {
			while(rs.next()) {
				int id = rs.getInt("employee_id");
				String firstName = rs.getString("first_name");
				String lastName = rs.getString("last_name");
				BigDecimal salary = rs.getBigDecimal("salary");
				System.out.println("Pracownik nr " + id + ": " + firstName + " " + lastName + " zarabia " + salary);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

}
