1

For nearly 2 hours now I'm looking for a solution, but can't find one ...

I'm getting this error and I can't find where it comes from, it's driving me crazy. Can you guys help me ?

The error :

java.sql.SQLException: Internal error when parsing callable statement metadata (missing parameter type)

And the part of the code where it comes from :

public char checkMap(int x, int y) {
        char c = ' ';

        try {
            DAOConnection co = new DAOConnection(DBConnection.getInstance().getConnection());

            final String sql = "{call Selectlvl1(?,?)}";
            final CallableStatement call = co.getConnection().prepareCall("{call Selectlvl1(?,?)}"); 
            call.setInt(x, x);
            call.setInt(y, y);
            call.execute();
            final ResultSet resultSet = call.getResultSet();
            c = resultSet.getString("symbol").charAt(0);

        } catch (SQLException se) {
            // Handle errors for JDBC
            se.printStackTrace();
        } catch (Exception e) {
            // Handle errors for Class.forName
            e.printStackTrace();

        }
        return c;

    }

EDIT : Just so you know, I've been driving some tests, and the line the error ca me up with is the "CallableStatement" one.

EDIT 2 : The SQL Procedure :

CREATE DEFINER = root@localhost PROCEDURE Selectlvl1(IN p_x INT(3), IN p_y INT(3)) SELECT symbol FROM LorannProject.level1 where x = p_x && y = p_y;

The Stack Trace ( part of it ) :

java.sql.SQLException: Illegal operation on empty result set. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:963) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860) at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:790) at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5240) at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5163) at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5202) at model.DAOConnection.checkMap(DAOConnection.java:24) at model.Model.getMap1(Model.java:41)

Note that now, after changing the call.setInt(), the error is now "Illegaloperation on empty result set.".

EDIT 3 : Just adding some news, I now have another error :

java.sql.SQLException: Illegal operation on empty result set.

I think ( pretty sure ) it comes from this line :

    c = resultSet.getString("symbol").charAt(0);

I am trying to take the first char from the only column called "symbol", I do not know if this line is right.

6
  • 1
    You probably meant : call.setInt(1, x); and call.setInt(2, y);. You have to provide the right index for each placeholder of your statement. Commented Jun 17, 2016 at 13:00
  • 1
    Please post the stack trace as well as the signature of the stored procedure. Commented Jun 17, 2016 at 13:08
  • Just added it. @Berger : It changes the error code but it does not work yet. Thank you mate ! Commented Jun 17, 2016 at 13:12
  • Have you looked at this question? Commented Jun 17, 2016 at 13:13
  • 1
    Now, the problem is you are not advancing the resultset cursor. You need to do a resultSet.next() before resultSet.getString() Commented Jun 17, 2016 at 13:19

1 Answer 1

0

Maybe you could try:

if (resultSet.next()) {
    c = resultSet.getString("symbol").charAt(0);
}
Sign up to request clarification or add additional context in comments.

3 Comments

Did it, now it shows some sprites, but not all of them. I still have the same error though, it is dealing with empty results. How can I say something like "if(resultSet.next() is empty){ c = '-'} ?
@Prototype When you initialize char c , just set it to '-' instead of a space. That way, if you don't go in the if statement, then c is '-'
you could also simple add an else block

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.