Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. Id Integer clave primaria auto increment
  2. numero_socio int
  3. nombre varchar
  4. apellidos varchar
  5. nif varchar
  6. fecha_nac date
  7. telefono int
  8. correo varchar
  9. direccion varchar
  10. fecha_alta date
  11. fecha_baja date
  12.  
  13. id clave primaria auto increment
  14. acta mediumtext
  15. tipo varchar
  16. fecha date
  17. convocante varchar
  18.  
  19. id clave primaria auto increment
  20. id_socio_presidente int (relación con id de un socio)
  21. id_socio_secretario int (relación con id de un socio)
  22. id_socio_vocal1 int (relación con id de un socio)
  23. id_socio_vocal2 int (relación con id de un socio)
  24. id_socio_vocal3 int (relación con id de un socio)
  25. id_asamblea int (relación con id de una asamblea)
  26. periodo varchar
  27.  
  28. void cargar(String valor) {
  29. try {
  30.  
  31. String[] titulos = {"Id", "Presidente", "Secretario", "Vocal 1", "Vocal 2", "Vocal 3", "Asamblea", "Periodo",};
  32. String[] registros = new String[8];
  33. model = new DefaultTableModel(null, titulos);
  34.  
  35.  
  36. String cons = "SELECT a.fecha AS FechaAsamblea,n"
  37. + "p.nombre AS NombrePresidente,n"
  38. + "p.apellidos AS ApellidosPresidente,n"
  39. + " jd.id,n"
  40. + " periodo,n"
  41. + " s.nombre AS NombreSecretario,n"
  42. + " s.apellidos AS ApellidosSecretario,n"
  43. + " v1.nombre AS NombreVocal1,n"
  44. + " v1.apellidos AS ApellidosVocal1,n"
  45. + " v2.nombre AS NombreVocal2,n"
  46. + " v2.apellidos AS ApellidosVocal2,n"
  47. + " v3.nombre AS NombreVocal3,n"
  48. + " v3.apellidos AS ApellidosVocal3n"
  49. + "FROM junta_directiva jdn"
  50. + "INNER JOIN socios p ON jd.id_socio_presidente = p.idn"
  51. + "INNER JOIN socios s ON jd.id_socio_secretario = s.idn"
  52. + "INNER JOIN socios v1 ON jd.id_socio_vocal1 = v1.idn"
  53. + "INNER JOIN socios v2 ON jd.id_socio_vocal2 = v2.idn"
  54. + "INNER JOIN socios v3 ON jd.id_socio_vocal3 = v3.idn"
  55. + "INNER JOIN asamblea a ON jd.id_asamblea = a.id";
  56.  
  57. Statement st = cn.createStatement();
  58.  
  59. ResultSet rs = st.executeQuery(cons);
  60.  
  61.  
  62. //Introducimos los registros de la base de datos en la tabla
  63. while (rs.next()) {
  64. registros[0] = rs.getString("jd.id");
  65. registros[1] = rs.getString("NombrePresidente") + " " + rs.getString("ApellidosPresidente");
  66. registros[2] = rs.getString("NombreSecretario") + " " + rs.getString("ApellidosSecretario");
  67. registros[3] = rs.getString("NombreVocal1") + " " + rs.getString("ApellidosVocal1");
  68. registros[4] = rs.getString("NombreVocal2") + " " + rs.getString("ApellidosVocal2");
  69. registros[5] = rs.getString("NombreVocal3") + " " + rs.getString("ApellidosVocal3");
  70. registros[6] = rs.getString("FechaAsamblea");
  71. registros[7] = rs.getString("periodo");
  72. model.addRow(registros);
  73. }
  74. jTable1.setModel(model);
  75.  
  76.  
  77. } catch (Exception e) {
  78. System.out.println(e.getMessage());
  79. }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement