tags:

views:

35

answers:

2

hi, i'm trying to get the type and the name of the result and when enter in the loop, excuting somo instructions about the metadata the resulset.next changed from true to false, and give the error java.sql.SqlExcepcion exhausted resultset. Any ideas? i really dont know how solved it because i read the post with the solution of this problem and validate if the resultset it's null before begin the loop. I'm called this method with a scheduler of quartz. I'm using this in a j2ee aplication and the example it's this

try 
    {
        InitialContext ctx = new InitialContext(); 
        WrapperDataSource wrapperDataSource = (WrapperDataSource)ctx.lookup(systemLogger.getConfigurationParameters().getDataSource());
        conn = wrapperDataSource.getConnection();

        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
        conn = DriverManager.getConnection(url,login,password);

        if (conn != null)
        {
             stmt = conn.createStatement();
             res = stmt.executeQuery(query);

             if (res != null)
             {
                 while (res.next())
                {
                    for (int i = 0; i < columnlength; i++) 
                    {
                        String columnName = metadata.getColumnName(i+1);
                        if (metadata.getColumnName(i+1).equalsIgnoreCase(systemLogger.getColumnStatus())) 
                        {
                            columnStatusType = metadata.getColumnType(i+1);
                        }
                        else if (metadata.getColumnName(i+1).equalsIgnoreCase(systemLogger.getColumnDocumentId()))
                        {
                            columnDocumentIdType =  metadata.getColumnType(i+1);
                        }
                        else if (metadata.getColumnName(i+1).equalsIgnoreCase(systemLogger.getColumnTimer()))
                        {
                            columnTimerType =  metadata.getColumnType(i+1);
                        }
                    }
                }
             }
             else
             {
                __log.error("No results found for the query");
                throw new PtmServiceException("No se encontraron resultados para el query");
             }

        }
        else
        {
            __log.error("Could not create the connection");
            throw new PtmServiceException("No se pudo crear la conexion");
        }

    } 
    catch(Exception e)
    {
        __log.error("Error in the execution of the query");
        throw new PtmServiceException("Error ejecutando la busqueda");
    }
    finally
    {
        res.close();
        stmt.close();
        conn.close();
    }
+1  A: 

The variable columnlength seems to hold a value larger than the number of columns returned by the query. Try with a smaller columnlength.

Victor Ionescu
A: 

finally, i see the problem, while i'm debugging the code with ecplise in the view of the expressions i added the follow expression res.next(), then each sentence that i pass for the step into bring the consequence that expression that evaluate if the resultset has more rows, be evaluated again. In some point the resultset has evaluated all the rows for each step into that i made in the process of debugging. The only thing that i have to do was eliminate the expression and works fine...

Jorge