oracle-databasespring-bootsingle-quotescallable-statementjava-stored-procedures

Missing right quote in callableStatement.getString result


I am calling an Oracle stored procedure from spring boot application. The SP will return either Y or N (status). It is working perfectly in SQL Navigator. But when i call it from Java I am getting the status as "Y (i.e. with an opening quote and no closing quote)

callableStatement.registerOutParameter("isavailableflag", OracleTypes.CHAR);
String isUserExists = callableStatement.getString("isavailableflag");

isUserExists = "Y

How to resolve this issue? For now, I am handling from Java but I am looking for a cleaner solution.

Stored Procedure

PROCEDURE isusernameavailable (applicationname IN VARCHAR2,
username IN VARCHAR2                                           
isavailableflag OUT CHAR)
.
.
.

Solution

  • Read the CHAR and convert it to String

    callableStatement.registerOutParameter("isavailableflag", OracleTypes.CHAR);
    String isUserExists = String.valueOf(callableStatement.getString("isavailableflag").charAt(0));