02/02/2018, 16:21
|
| | | Fecha de Ingreso: noviembre-2012 Ubicación: Lima
Mensajes: 51
Antigüedad: 12 años, 1 mes Puntos: 0 | |
SOLUCION FINAL Problemas con Query de java y mysql
GRACIAS POR LA AYUDA EN REALIDAD SON LO MAXIMO.
Código:
public void MostrarRegistroflota() {// FUNCIONAL--------
try {
Conn = Mysql.getConecion();
DefaultTableModel miModelo = null;
String[] titulos = {"Codigo Registro","Fecha","Codigo Unidad","Codigo Chofer","Codigo Lider","Codigo Aux 1","Codigo Aux2","Observaciones"};
String query =("select t1.codregistro,t1.fecha, t2.placa as Placa, t3.apellidos as Chofer, t4.apellidos as Lider, t5.apellidos as Auxiliar1, t6.apellidos as Auxiliar2, t1.observacion as Observacion from registroflota as t1"
+ " inner join unidad as t2 on (t1.cod_unidad = t2.codunidad)"
+ "inner join personal as t3 on (t1.cod_chofer = t3.codpersonal)"
+ "inner join personal as t4 on (t1.cod_lider = t4.codpersonal)"
+ "inner join personal as t5 on (t1.cod_auxiliar1 = t5.codpersonal)"
+ "inner join personal as t6 on (t1.cod_auxiliar1 = t6.codpersonal)");
miModelo = new DefaultTableModel(null, titulos);
sent = Conn.createStatement();
ResultSet rs = sent.executeQuery(query);
Object [] fila = new Object[8];
while(rs.next()){
fila[0] = rs.getInt("codregistro");
fila[1] = rs.getDate("fecha");
fila[2] = rs.getString("Placa");
fila[3] = rs.getString("Chofer");
fila[4] = rs.getString("Lider");
fila[5] = rs.getString("Auxiliar1");
fila[6] = rs.getString("Auxiliar2");
fila[7] = rs.getString("Observacion");
miModelo.addRow(fila);
//System.out.println(fila[2]);
}
//asigna el modelo a la tabla
tablaflota.setModel(miModelo);
}catch(Exception ex) {
}
finally {
try {
Conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}// fin del metodo MOSTARR REGISTRSO
|