Hi!
Im doing a program in java that gets info from a database.. thing is that im seting a variable with data from one table, and one data is char and cant find the way to have the .getChar() like the rs.getString()
the code is:
public ModosDeCompra_clase dameModoCompra(Integer id)
{
ModosDeCompra_clase mdc = new ModosDeCompra_clase();
Statement comando;
boolean seguir;
ResultSet rs;
try
{
comando = conexiones.cnn.createStatement();
rs = comando.executeQuery("SELECT id_provincia,nombre_provincia FROM provincias WHERE id_provincia ="+ id);
seguir = rs.next();
while (seguir)
{
mdc.setId_mododecompra(rs.getByte(1));
mdc.setNombre(rs.getString(2));
mdc.setHabilitado(rs.getArray(3));
seguir = rs.next();
}
return mdc;
}
catch(Exception e)
{
JOptionPane.showMessageDialog (null,e.getMessage()+"error en -dameModoCompra(Integer id)-");
return null;
}
}
and i use it here:
public boolean mostrarConsulta() // this is to show a list of the things i've stored in the db
{
Tipos_Insumos_Clase mdcActual;
boolean seguir;
ResultSet rs;
Statement comand;
listaTiposInsumos.clear();
try
{
listTiposInsumos.removeAll();
conexiones.conectaralabase();
comand = conexiones.cnn.createStatement();
rs = comand.executeQuery("SELECT id_insumo,nombre_insumo,forma_compra,habilitado FROM tipos_insumos WHERE habilitado = 1 ORDER BY nombre_insumo");
seguir = rs.next();
while (seguir)
{
mdcActual = new Tipos_Insumos_Clase();
mdcActual.setId_insumo(rs.getInt(1));
mdcActual.setNombre_insumo(rs.getString(2));
mdcActual.setMedida_insumo(dameModoCompra(rs.getInt(3)));
listaTiposInsumos.add(mdcActual);
seguir = rs.next();
}
listTiposInsumos.setListData(listaTiposInsumos.toArray());
return true;
}
catch (Exception e)
{
JOptionPane.showMessageDialog (null,e.getMessage());
return false;
}
}
thanks in advanced