Prototype
Prototype

Reputation: 132

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

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.

Upvotes: 1

Views: 1446

Answers (1)

Nico
Nico

Reputation: 3542

Maybe you could try:

if (resultSet.next()) {
    c = resultSet.getString("symbol").charAt(0);
}

Upvotes: 0

Related Questions