Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-1183

Client java.sql.ResultSet.getCursorName() does not return the correct cursor name for Statements after the first execution

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.2.1.6
    • 10.2.1.6
    • JDBC
    • None

    Description

      For client, if the cursor name is set with java.sql.Statement.setCursorName() the name set by the user only applies to the first execution. Subsequent executions use the default cursor name. To reproduce run the progam below as follows:

      D>java -Dframework=DerbyNetClient GetCursorName
      10.2.0.0 alpha
      Apache Derby
      Apache Derby Network Client JDBC Driver
      rs.getCursorName():MyCursor
      rs.getCursorName():SQL_CURLH000C2

      With embedded it is ok:
      D>java GetCursorName
      10.2.0.0 alpha
      Apache Derby
      Apache Derby Embedded JDBC Driver
      rs.getCursorName():MyCursor
      rs.getCursorName():MyCursor

      import java.sql.Connection;
      import java.sql.DatabaseMetaData;
      import java.sql.ResultSet;
      import java.sql.SQLException;
      import java.sql.Statement;

      import org.apache.derbyTesting.functionTests.util.TestUtil;

      class GetCursorName
      {

      public static void main (String args [])throws Exception

      { testGetCursorName(); }

      public static void testGetCursorName() throws SQLException

      { Connection conn = TestUtil.getConnection("wombat","create=true"); Statement stmt = null; ResultSet rs = null; DatabaseMetaData md = conn.getMetaData() ; System.out.println(md.getDatabaseProductVersion()); System.out.println(md.getDatabaseProductName()); System.out.println(md.getDriverName()); stmt = conn.createStatement(); // Setting the cursor name works for one execution ok. stmt.setCursorName("MyCursor"); rs = stmt.executeQuery("select count(*) from sys.systables"); System.out.println("rs.getCursorName():" + rs.getCursorName()); rs.close(); //Executing another query seems to clears the cursor name. // getCursorName() will print the default cursor name SQLXXX. rs = stmt.executeQuery("select count(*) from sys.systables"); System.out.println("rs.getCursorName():" + rs.getCursorName()); rs.close(); stmt.close(); conn.close(); }

      }

      I noticed this bug when coverting the checkDataSource test for client.
      I will change that test to set the cursor name for each execution for client.

      Attachments

        1. derby-1183.diff
          20 kB
          Dag H. Wanvik
        2. derby-1183.stat
          0.7 kB
          Dag H. Wanvik
        3. derby-1183-2.diff
          22 kB
          Dag H. Wanvik
        4. derby-1183-2.stat
          0.8 kB
          Dag H. Wanvik

        Activity

          People

            dagw Dag H. Wanvik
            kmarsden Katherine Marsden
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: