package ufe.jdbc;

import java.sql.*;
import ufe.jdbc.util;

public class Test2 {

  public static void main(String[] args)
      throws SQLException, ClassNotFoundException, java.io.IOException {
    try (
            Connection conn =
                    ConfigConnection.getConnection("/fichierprop.txt");
            Statement stmt = conn.createStatement();) {
      ResultSet rset = stmt.executeQuery("SELECT nomd, count(*) "
					 + "from emp, dept "
                     + "where emp.dept = dept.dept "
					 + "group by nomd "
					 + "ORDER BY nomd");

      System.out.println("Nom de la table : "
              + rset.getMetaData().getTableName(1));
      System.out.println("Type de la colonne  : "
              + rset.getMetaData().getColumnType(1));
      System.out.println("Nom de la colonne : "
              + rset.getMetaData().getColumnName(1));

      // Récupère les données
      while (rset.next()) {
	System.out.println(rset.getString(1) + " a "
			   + rset.getInt(2) + " employes");
      }
    }
  }
}
