I am trying to call the Oracle stored procedure in java. I have given below,stored procedure and java method which calls the stored procedure and returns the result set. I am getting the error Invalid column type :1111 or invalid column index.
Can anyone tell me whats wrong in the code
Oracle Stored Procedure:

          cur_out OUT PACK_OGPT.t_cursor 
         OPEN cur_out FOR 
         FROM  book; 
END spDisplayBook;

private ResultSet execSQL(String sqlStr) throws Exception {
if (con==null) {
  System.err.println("Database connection is closed.");
ResultSet rs=null;
try {

        String query = "begin ? := spDisplayBook; end;";

        CallableStatement statement = con.prepareCall (query);
        statement.registerOutParameter(1, OracleTypes.OTHER);
        rs = (ResultSet)statement.getObject(1);

        while (rs.next())
            System.out.println(rs.getString(1).toString()+ rs.getString(2).toString());
    catch (SQLException sqle) {
    System.err.println("Check your SQL statement:");
    int ErrCode = sqle.getErrorCode();
    String str = sqle.getMessage();

return rs;

Edited 3 Years Ago by pritaeas: Fixed formatting

Dear Friend, this error can be due to the difference in data type of the column name and the data you're passing. The data type doesn't match. Maybe in the database the Field is defined as type integer and you've passed String value to it. Anyway the error is due to the difference in the type of the data. Cross check this in the code. You've to see the design of the database table and check the type of the data defined for each field and check it with the java code whether you're passing the data of the same type. Have a great day!!

And actually the error is happening in the code

statement.registerOutParameter(1, OracleTypes.OTHER);

Am not getting one thing, I want to fetch all the fields from the table. How to do it? Please tell me how to fetch the data from the query SELCET * FROM TABLENAME; into the resultset.

Dear Friend, You have to store the values taken from the database directly to the ResultSet Object. That is it must be like:

ResultSet rest = statement.execute();

After that you can take out each of the records from the ResultSet object. If you have any doubts kindly let me know. Have a great day!!

This article has been dead for over six months. Start a new discussion instead.