Hi all,
im doing a program using java and sql, and im trying to set a textbox with a value stored in a database.
thing is: i have a combo with airlines, and each airline has a cost for each seat. so what im trying to do is get this cost per seat and then multiply it per people traveling.
what i did is:
int cantidadgente;
float valortotalvuelos;
float valordelaclase;
Statement sql;
ResultSet rs;
boolean seguir;
Aerolineas_clase aerolinea;
cantidadgente=Integer.parseInt(txtCantidadPersonas.getText());
if (validarseleccioncomboaerolinea())
{
// valortotalvuelos=;
cmbAerolinea.getSelectedItem().toString();
try
{
sql = conexiones.cnn.createStatement();
aerolinea = new Aerolineas_clase();
rs = sql.executeQuery("SELECT id_aerolinea,nombre_aerolinea,clase_aerolinea,costo FROM aerolineas WHERE nombre_aerolinea =" + cmbAerolinea.getSelectedItem().toString()); //here i compare to the string i have selected in the combo
rs.next();
//with --> aerolinea.setPrecio(rs.getFloat(4)) --> i get the value for the seat
valordelaclase = Float.parseFloat(aerolinea.setPrecio(rs.getFloat(4))); // 'void' type not allowed here
}
catch (Exception e)
{JOptionPane.showMessageDialog (null,e.getMessage()+"error getAerolinea");}
txtTotalAerolinea.setText(null);
}
idk how to set the value from the airline into a value i can use. have tried doing:
valortotalvuelos = (aerolinea.setPrecio(rs.getFloat(4))) * candidadgente; // 'void' type not allowed here
but still gives me that error.
thanks in advance!