Created by
Mihamina Rakotomandimby
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.mavenproject1;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author SD927019
*/
public class Employe {
private static String url = "jdbc:postgresql://localhost:5432/test";
private static String user = "test";
private static String password = "test";
public static void printLines() {
try (Connection con = DriverManager.getConnection(url, user, password);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT "
+ " civil_status.id, "
+ " first_name, "
+ " last_name, "
+ " emp_contract.gross_salary, "
+ " pay_accu.worked_hours, "
+ " (emp_contract.gross_salary - pay_accu.taxes) imposable_non_soumis "
+ "FROM civil_status "
+ "JOIN emp_contract ON emp_contract.civil_statusid = civil_status.id "
+ "JOIN emp_contract_pay_period ON emp_contract_pay_period.emp_contractid = emp_contract.id "
+ "JOIN pay_accu ON pay_accu.emp_contract_pay_periodid = emp_contract_pay_period.id ")) {
while (rs.next()) {
System.out.println(
rs.getString(1) +',' // Matricule
+ rs.getString(2) +',' // Prenom
+ rs.getString(3) +',' // Nom
+ rs.getString(4) +',' // Salaire brut
+ rs.getString(5) +',' // Heures
+ rs.getString(6) // Net
);
}
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
}
|