Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/05/2012, 19:54
arco_iris
 
Fecha de Ingreso: mayo-2012
Mensajes: 3
Antigüedad: 12 años
Puntos: 0
Pregunta Base de datos MySql para conectar a un web service

Holaaa, soy nueva aqui espero me ayuden con un problemilla..
tengo que realizar un web services Banco que este conectado a una base de datos, estoy utilizando mysql, en un metodo que se llama transferir(lo que hace es recibir dos cuentas uno origen y el otro destino, y el monto a transferir), me esta dando errores y retorna cualquier cosa.. si pueden mirar... graciasss

public String transferir(String origen, String destino, double monto){

String res = "";
String retorna = "";
int bandera = 0;
Double fondo = 0.0;
try {
statement = connection.createStatement();
//PARA CONTROLAR SI EXISTE CUENTA ORIGEN Y DESTINO
//SI NO EXISTEN DEVUELVE MSG DE ERROR
if(bandera == 0 ){
resultSet = statement.executeQuery("SELECT id_cuenta FROM cuenta WHERE id_cuenta='"+origen+"'");
if( !( ( "".equals( resultSet.getString("id_cuenta") ) ) == true) ){
retorna = "CUENTA ORIGEN NO EXISTE...";
}else{
resultSet = statement.executeQuery("SELECT id_cuenta FROM cuenta WHERE id_cuenta='"+destino+"'");
if(("".equals(resultSet.getString("id_cuenta"))) == true ){
retorna = "CUENTA DESTINO NO EXISTE...";
}else{
bandera = 1;
}
}
}

//VERIFICAR SI CUENTA ORIGEN TIENE EL MONTO SUFICIENTE PARA REALIZAR
//LA TRANSFERENCIA

if(bandera == 1){
resultSet = statement.executeQuery("SELECT monto FROM cuenta WHERE id_cuenta='"+origen+"'");
res = resultSet.getString("monto");
if( !( ("".equals(res) ) == true) ){
retorna = "LA CUENTA ORIGEN NO TIENE FONDOS...";
}else{
fondo = Double.parseDouble(res);
if( fondo >= monto){
//Se realiza la transferencia
Double result = (fondo - monto);
int x = statement.executeUpdate("UPDATE cuenta SET monto='"+result.toString()+"'"+"WHERE id_cuenta='"+origen+"'");
resultSet = statement.executeQuery("SELECT monto FROM cuenta WHERE id_cuenta="+destino);
res = resultSet.toString();
fondo = Double.parseDouble(res);
result = (fondo + monto);
int y = statement.executeUpdate("UPDATE cuenta SET monto='"+result.toString()+"'"+"WHERE id_cuenta='"+destino+"'");
retorna = "LA TRANSFERENCIA HA SIDO EXITOSA...";
}else{
retorna = "CUENTA ORIGEN NO POSEE MONTO SUFICIENTE...";
}
}
}
}catch (SQLException ex) {
System.out.println(ex);
}
return retorna;
}

solo me retorna "", no esta entrando en los if y no se porque... porfa necesito ayuda