Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/07/2008, 01:16
txiti
 
Fecha de Ingreso: junio-2008
Mensajes: 168
Antigüedad: 15 años, 10 meses
Puntos: 0
Pregunta Consulta SqlExceptio column not found



Buenas!!!

intento hacer una simple consulta en el mysql todo perfecto pero cuando lo realizo desde el jbuilder no me coje el valor siempre me devuelve 0 y no debería ser así;alguien me puede ayudar por favor, muchas gracias..ahí os dejo el codigo:

//este es el error q salta
java.sql.SQLException: Column 'cod' not found.

//subprograma:

//obtener el cod materia dado un codGrupo
public int obtCodMateria(String pCodGrupo,Connection pCon) throws
SQLException {
int codMateria = 0;
String sql="SELECT codMateria FROM grupo WHERE cod='"+pCodGrupo+"';";
Statement stmt = pCon.createStatement();
ResultSet rs = stmt.executeQuery(sql);
boolean enc=false;

try {
while (!enc && rs.next()) {
String codigo = rs.getString("cod");
codMateria = rs.getInt("codMateria");

if (codigo.compareTo(pCodGrupo) == 0) {
enc = true;
}
}
} catch (SQLException ex) {
System.out.println(ex);
}
return codMateria;
}