I need to make a query with the function count
of plsql
that returns me the number of rows of a query that meets some requirements to then do a if
, but I can not get anything back. This is the piece of code.
Class.forName(driver);
con = DriverManager.getConnection(url, usuariobd, clave);
/*guardando la conexion en la session*/
session.setAttribute("conexion", con);
Statement com = con.createStatement();
String textoComando = "SELECT count(idTitulacion) NumeroFilas FROM titulacionalumnos where nombre='" + titulo + "' and centroTitulo='" + centroTitulo + "'; ";
ResultSet resultado = com.executeQuery(textoComando);
int numFilas=0;
while (resultado.next()) {
numFilas=resultado.getInt("NumeroFilas");
out.println("<h1>numero de filas: " + numFilas + "</h1>");
if (numFilas == 0) {
out.println("<div>No existe este titulo. Se registrara el nuevo titulo</div>");
} else {
out.println("<div>El titulo es " + titulo + " " + centroTitulo + "</div>");
}
}
The connection to the database is fine, and the values that I pass from a form also picks them up well. Thanks