Foros del Web » Programación para mayores de 30 ;) » Java »

[SOLUCIONADO] At least one parameter to the current statement is uninitialized.

Estas en el tema de At least one parameter to the current statement is uninitialized. en el foro de Java en Foros del Web. Buenas a todos, estoy intentado guardar unos datos en una tabla usando java y con apache derby y me arroja este error y no consigo ...
  #1 (permalink)  
Antiguo 10/08/2014, 04:34
Avatar de Pike  
Fecha de Ingreso: agosto-2008
Ubicación: Por ahí
Mensajes: 251
Antigüedad: 15 años, 8 meses
Puntos: 1
At least one parameter to the current statement is uninitialized.

Buenas a todos,

estoy intentado guardar unos datos en una tabla usando java y con apache derby y me arroja este error y no consigo ver cual es el problema. Parece que pueda estar en el preparedStatement pero ni idea...adjunto al código donde intuyo que puede estar el problema:

Código HTML:
Ver original
  1. public void guardaUbicacion(Ubicacion ubicacion)throws XeladoException{
  2.         Piedra piedra=null;
  3.        // List<Ubicacion>ubis = new ArrayList<Ubicacion>();
  4.         try{
  5.             introPiedraSt.setString(1,ubicacion.getPiedra().getID_Piedra());
  6.             introPiedraSt.executeUpdate();
  7.             ResultSet rs= introPiedraSt.getGeneratedKeys();
  8.             rs.next();
  9.             String id= rs.getString("id_piedra");
  10.             piedra.setId_Piedra(id);
  11.            
  12.             while(rs.next()){
  13.                // ubicacion = new Ubicacion(piedra,rs.getInt("fila"),rs.getInt("columna"));
  14.               //  ubis.add(new Ubicacion(piedra,rs.getInt("fila"),rs.getInt("columna")));
  15.                 for(Ubicacion ubicaciones:piedra.getPiedras()){
  16.                     introPiedraUbicacionSt.setString(1,ubicaciones.getPiedra().getID_Piedra());
  17.                     introPiedraUbicacionSt.setInt(2,ubicaciones.getFila());
  18.                     introPiedraUbicacionSt.setInt(3,ubicaciones.getColumna());
  19.                     introPiedraUbicacionSt.executeUpdate();
  20.                 }
  21.             }
  22.         }catch(SQLException ex){
  23.             System.err.println(ex.getMessage());
  24.         }
  25.     }

Un saludo a todos
  #2 (permalink)  
Antiguo 10/08/2014, 05:06
Avatar de chuidiang
Colaborador
 
Fecha de Ingreso: octubre-2004
Mensajes: 3.774
Antigüedad: 19 años, 7 meses
Puntos: 454
Respuesta: At least one parameter to the current statement is uninitialized.

Difícil sin saber la línea exacta ni ver los preparedStatement (hay dos).

Ese error suele ser que un preparedStatement lleva varios ? y alguno te dejas sin rellenar. Según el código, el primero (introPrieraSt) debería solo llevar uno y el segundo (introPriedraUbicacionSt) debería llevar sólo 3.

Se bueno.
__________________
Apuntes Java
Wiki de Programación
  #3 (permalink)  
Antiguo 10/08/2014, 05:56
Avatar de Pike  
Fecha de Ingreso: agosto-2008
Ubicación: Por ahí
Mensajes: 251
Antigüedad: 15 años, 8 meses
Puntos: 1
Respuesta: At least one parameter to the current statement is uninitialized.

Estas son las consultas sobre las que hago los preparedStatement

Código HTML:
Ver original
  1. private static String introPiedraUbicacionSQL = ""
  2.        
  3.             + " INSERT INTO ubicaciones(id_piedra,fila,columna)"
  4.             + " VALUES (?, ?, ?)";
  5.     private static String introPiedraSQL =""
  6.  
  7.             + " INSERT INTO piedras(id_piedra,peso)"
  8.             + " VALUES(?,?)";

Muchas gracias por tu respuesta.
  #4 (permalink)  
Antiguo 10/08/2014, 09:19
Avatar de Pike  
Fecha de Ingreso: agosto-2008
Ubicación: Por ahí
Mensajes: 251
Antigüedad: 15 años, 8 meses
Puntos: 1
Respuesta: At least one parameter to the current statement is uninitialized.

SOLUCIONADO !!!

Muchas gracias por tu ayuda

Etiquetas: parameter, statement, string
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:43.