I'm new to the connectivity between Java and Oracle and I'm designing a login page.
I'm attempting to call an Oracle function from JAVA. Assume the Oracle function is called FUNCT_PERSON with 2 IN parameters: username and password and return the user id which is a NUMBER.
Inside the FUNCT_PERSON function we use a SELECT statement and return user id number if found, otherwise it will return 0.
Here is my code:
String sql = "{ ? = call FUNCT_PERSON(?,?) }";
CallableStatement statement = connection.prepareCall(sql);
statement.setString(2,username);
statement.setString(3,password);
statement.registerOutParameter(1, java.sql.Types.INTEGER);
Boolean check = statement.execute();
if (!check) {
//proceed to another page
} else {
//Go back to the login page
}
I don't know if what I'm doing is right or not, especially the Boolean check = statement.execute(); line, because I don't really know what the check is for..
If the function return a user ID, that means it exists in the database and I'll proceed to another page. If not, then it will redirect to the login page.