• Viernes 29 de Marzo de 2024, 15:22

Autor Tema:  java.lang.ArrayIndexOutOfBoundsException  (Leído 1870 veces)

LordJhony

  • Miembro activo
  • **
  • Mensajes: 70
    • Ver Perfil
java.lang.ArrayIndexOutOfBoundsException
« en: Jueves 28 de Octubre de 2010, 17:41 »
0
Hola....
Se Que Ese Error Se Presenta Porque Intento Acceder A Una Posicion Inexistente En Un Arreglo. Ahi Es Donde No Entiendo Porque La Posicion Que Estoy Intentando Acceder Si Existe.
Lo Que Yo Hago Es Hacer Una Consulta A Mi Base De Datos, Tomo Uno De Los Resultados y Simplemente Quiero Mostrarlo Y Ahi es Donde Se Presenta El Error:
Citar
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.ArrayIndexOutOfBoundsException: 1
note The full stack traces of the exception and its root causes are available in the GlassFish/v3 logs.


--------------------------------------------------------------------------------

GlassFish/v3
Miren El Codigo:
Código: Java
  1. try
  2.         {
  3.             if(req.getParameter("B1")!=null)
  4.             {
  5.                String q="select * from simulador_ecaes.pregunta where Id_Componente='"+id+"'order by rand()limit 0,1";
  6.                try
  7.                {
  8.                 bd.valida = bd.ingreso.executeQuery(q);
  9.                 while(bd.valida.next())
  10.                 {
  11.                     String pre=bd.valida.getString("Id_Pregunta");
  12.                     pag.println(pre);
  13.                 }
  14.                }catch(SQLException e){}
  15.             }
  16.         }
  17.         catch(Exception e){}
  18.  
La Verdad Yo No Veo Ningun Problema. Espero Y Me Puedan Colaborar Diciendome Que me Genera El Error Y Como Solucionarlo.
Muchas Gracias

m0skit0

  • Miembro de PLATA
  • *****
  • Mensajes: 2337
  • Nacionalidad: ma
    • Ver Perfil
    • http://fr33kk0mpu73r.blogspot.com/
Re: java.lang.ArrayIndexOutOfBoundsException
« Respuesta #1 en: Viernes 29 de Octubre de 2010, 13:37 »
0
¿En qué línea concretamente te da el error?

LordJhony

  • Miembro activo
  • **
  • Mensajes: 70
    • Ver Perfil
Re: java.lang.ArrayIndexOutOfBoundsException
« Respuesta #2 en: Viernes 29 de Octubre de 2010, 13:56 »
0
Gracias... Ya He Solucionado El Problema... Resulta Que La Variable "id"
Del Query No Le Estaba Llegando Informacion Del Jsp