JDBC T2 driver returns error 8813 accessing the ResultSet of a select count(*) statement

Bug #1274281 reported by Weishiun Tsai
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Trafodion
Fix Released
High
Pavani Puppala

Bug Description

With the JDBC T2 driver, fetching the ResultSet of a select count(*) statement returns the following error:

*** ERROR[8813] Trying to fetch from a statement that is in the closed state.

This is seen using the beta build trafodion-ci-release-trafodion_beta-20140128-v37024_release.tar.

Here is a small JDBC program to reproduce this problem:

-bash-4.1$ cat mytest.java
import java.sql.*;
import java.math.*;
import java.util.*;
import java.io.*;

public class mytest
{
    public static void main(String[] args) //throws java.io.IOException
    {
        Properties props = null;
        Connection conn = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        String cat = null;
        String sch = null;
        String url = null;
        String query = null;

        try
        {
            String propFile = System.getProperty("hpjdbc.properties");
            if (propFile != null)
            {
                FileInputStream fs = new FileInputStream(new File(propFile));
                props = new Properties();
                props.load(fs);

                url = props.getProperty("url");
                cat = props.getProperty("catalog");
                sch = props.getProperty("schema");
            }
            else
            {
                System.out.println("ERROR: hpjdbc.properties is not set. Exiting.");
                System.exit(0);
            }

            Class.forName("com.hp.sqlmx.SQLMXDriver");
            conn = DriverManager.getConnection(url, props);

            conn.createStatement().execute("drop table if exists tb");
            conn.createStatement().execute("create table tb (c1 int not null)");
            conn.createStatement().execute("insert into tb values (1),(2),(3),(4),(5),(6),(7),(8),(9)");

            System.out.println("select count(*)");
            rs = conn.createStatement().executeQuery("select count(*) from tb");
            System.out.println("rs.next()");
            if (rs.next() != false)
            {
                System.out.println("rs.getInt()");
                System.out.println(rs.getInt(1));
            }

            conn.close();
        }
        catch (SQLException se)
        {
            System.out.println("ERROR: SQLException");
            se.printStackTrace();
            System.out.println(se.getMessage());
            System.exit(1);
        }
        catch (Exception e)
        {
            System.out.println("ERROR: Exception");
            e.printStackTrace();
            System.out.println(e.getMessage());
            System.exit(1);
        }
    }
}

Here is the output of the program:

-bash-4.1$ myrun.sh
select count(*)
rs.next()
ERROR: SQLException
*** ERROR[8813] Trying to fetch from a statement that is in the closed state.

Changed in trafodion:
milestone: none → r0.7
tags: added: client-jdbc-t2
removed: sql
Revision history for this message
Weishiun Tsai (wei-shiun-tsai) wrote :

Try them on the beta v39140 build, the problem still exists

-bash-4.1$ myrun.sh
select count(*)
rs.next()
ERROR: SQLException
*** ERROR[8813] Trying to fetch from a statement that is in the closed state.

Changed in trafodion:
status: New → In Progress
Changed in trafodion:
assignee: nobody → Kevin Xu (kai-hua-xu)
Changed in trafodion:
assignee: Kevin Xu (kai-hua-xu) → Pavani Puppala (pavani-puppala)
Revision history for this message
Pavani Puppala (pavani-puppala) wrote :

SQL is setting the query type as SQL_EXE_UTIL instead of SQL_SELECT_NON_UNIQUE for select count(*) statements.

tags: added: sql-exe
removed: client-jdbc-t2
Changed in trafodion:
status: In Progress → Fix Committed
Revision history for this message
Weishiun Tsai (wei-shiun-tsai) wrote :

Verified on the GIT 0603_0930 build. This problem has been fixed:

-bash-4.1$ myrun.sh
select count(*)
rs.next()
rs.getInt()
9

Changed in trafodion:
status: Fix Committed → Fix Released
information type: Proprietary → Public
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers