Skip to content

Commit

Permalink
Añadida función devolverValorDouble
Browse files Browse the repository at this point in the history
  • Loading branch information
DiscoDurodeRoer committed Jul 27, 2018
1 parent 553769f commit 308ed60
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/conexiondb/ConexionDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 325,29 @@ public int devolverValorInt(String columna, String tabla, String condicion) {

}

/**
* Devuelve un valor int, recomendado para valores únicos
*
* @param columna Nombre de la columna de la base de datos
* @param tabla Nombre de la tabla de la base de datos
* @param condicion Condicion (sin where)
* @return Valor que devuelve la consulta
*/
public double devolverValorDouble(String columna, String tabla, String condicion) {

try (Statement sentenciaAux = conexion.createStatement();
ResultSet aux = sentenciaAux.executeQuery("select " columna " from " tabla " where " condicion);) {

aux.next();
return aux.getDouble(1);

} catch (SQLException ex) {
Logger.getLogger(ConexionDB.class.getName()).log(Level.SEVERE, null, ex);
return -1;
}

}

/**
* Devuelve un unico valor String
*
Expand Down

0 comments on commit 308ed60

Please sign in to comment.