ResultSetTest (jTDS API)
Date: 2013-06-08

net.sourceforge.jtds.jdbc

## Class ResultSetTest

- java.lang.Object
- - TestCase
  - - net.sourceforge.jtds.jdbc.TestBase
    - - net.sourceforge.jtds.jdbc.DatabaseTestCase
      - - net.sourceforge.jtds.jdbc.ResultSetTest

-     public class ResultSetTest
      extends DatabaseTestCase

  Version:
    1.0

- - ### Field Summary

    - ### Fields inherited from class net.sourceforge.jtds.jdbc.TestBase

      `con, props`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ResultSetTest(java.lang.String name)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `private static java.lang.String` | `array2String(java.lang.Object[] a)`
    `static void` | `main(java.lang.String[] args)`
    `void` | `testAbsoluteLargeValue()` Test that calling `absolute()` with very large positive values positions the cursor after the last row and with very large negative values positions the cursor before the first row.
    `void` | `testAbsoluteMinusOne()` Test that `absolute(-1)` works the same as `last()`.
    `void` | `testAutoIncrement()` Test for bug #690, IS_AUTOINCREMENT invalid for identity columns.
    `void` | `testBug644()` Test for bug #644, updateNull not working with MSSQL DECIMAL field.
    `void` | `testCancelResultSet()` Test for bug [1246270] Closing a statement after canceling it throws an exception.
    `void` | `testConcurrentResultSets()` Test for bug [2051585], TDS Protocol error when 2 ResultSets on the same connection are being iterated at the same time.
    `void` | `testCursorFallback()` Test that the cursor fallback logic correctly discriminates between "real" sql errors and cursor open failures.
    `void` | `testCursorFetch()` Test the behavior of `sp_cursorfetch` with fetch sizes greater than 1.
    `void` | `testCursorMaxRows()` Test that `Statement.setMaxRows()` works on cursor `ResultSet`s.
    `void` | `testCursorPrevious()` Test that `ResultSet.previous()` works correctly on cursor `ResultSet`s.
    `void` | `testCursorWarning()` Test for bug [1022445] Cursor downgrade warning not raised.
    `void` | `testDatePerformance()` Test for bug #548, Select statement very slow with date parameter.
    `void` | `testDateType()` Test for the problem reported in feature request #78, columns of type DATE are returned as String.
    `void` | `testDeleteRowMarksDeleted()` Test that deleted rows are not removed but rather marked as deleted.
    `void` | `testDistinctBug()` Test bug with Sybase where readonly scrollable result set based on a SELECT DISTINCT returns duplicate rows.
    `void` | `testDynamicCursors()` Test if dynamic cursors (`ResultSet.TYPE_SCROLL_SENSITIVE+1`) see others' updates.
    `void` | `testEmptyInsertRow()` Test that `insertRow()` works with no values set.
    `void` | `testGetByName()` Test whether retrieval by name returns the first occurence (that's what the spec requires).
    `void` | `testGetObject1()` Test BIT data type.
    `void` | `testGetObject2()` Test TINYINT data type.
    `void` | `testGetObject3()` Test SMALLINT data type.
    `void` | `testGetObject4()` Test INT data type.
    `void` | `testGetObject5()` Test BIGINT data type.
    `void` | `testInsertRowVisible()` Test that inserted rows are visible in a scroll sensitive `ResultSet` and that they show up at the end.
    `void` | `testMaxRows()` Check whether `Statement.setMaxRows()` works okay, bug [1812686].
    `void` | `testMoreThan255Columns()` Test if COL_INFO packets are processed correctly for `ResultSet`s with over 255 columns.
    `void` | `testNegativeOverflow()` Test for bug [2860742], getByte() causes overflow error for negative values.
    `void` | `testNumericOverflow()` Test for bug [1855125], numeric overflow not reported by jTDS.
    `void` | `testOutOfMemory()` Test the behavior of the ResultSet/Statement/Connection when the JVM runs out of memory (hopefully) in the middle of a packet.
    `void` | `testPessimisticConcurrency()` Test pessimistic concurrency for SQL Server (for Sybase optimistic concurrency will always be used).
    `void` | `testRelative()` Test for bug [1182066] regression bug resultset: relative() not working as expected.
    `void` | `testRelativeLargeValue()` Test that calling `absolute()` with very large positive values positions the cursor after the last row and with very large negative values positions the cursor before the first row.
    `void` | `testResultSetColumnName1()` Test for bug [1009233] ResultSet getColumnName, getColumnLabel return wrong values
    `void` | `testResultSetMetaData()` Test for fixed bugs in ResultSetMetaData: isNullable() always returns columnNoNulls.
    `void` | `testResultSetScroll1()` Test for bug [961594] ResultSet.
    `void` | `testResultSetScroll2()` Test for bug [945462] getResultSet() return null if you use scrollable/updatable.
    `void` | `testResultSetScroll3()` Test for bug [1028881] statement.execute() causes wrong ResultSet type.
    `void` | `testResultSetUpdate1()` Test for bug [1008208] 0.9-rc1 updateNull doesn't work.
    `void` | `testRowstat()` Test for bug [1329765] Pseudo column ROWSTAT is back with SQL 2005 (September CTP).
    `void` | `testSetObjectScale()` Test for bug [1075977] `setObject()` causes SQLException.
    `void` | `testUnicodeStream()` Test that `read()` works ok on the stream returned by `ResultSet.getUnicodeStream()` (i.e. it doesn't always fill the buffer, regardless of whether there's available data or not).
    `void` | `testUpdateableClientCursor()` Test for bug [1197603] Cursor downgrade error in CachedResultSet -- updateable result sets were incorrectly downgraded to read only forward only ones when client side cursors were used.
    `void` | `testUpdateRowDuplicatesRow()` Test that updated rows are marked as deleted and the new values inserted at the end of the `ResultSet` if the primary key is updated.
    `void` | `testUpdateRowNoChanges()` Test for bug [1170777] resultSet.updateRow() fails if no row has been changed.
    `void` | `testUpdateRowPosition()` Test that after updateRow() the cursor is positioned correctly.
    `void` | `testUpdateRowUpdatesRow()` Test that updated rows are modified in place if the primary key is not updated.
    `void` | `testZeroFetchSize()` Test for bug [1232733] setFetchSize(0) causes exception.

    - ### Methods inherited from class net.sourceforge.jtds.jdbc.DatabaseTestCase

      `compareBytes, getLongString, getLongString, getType, getTypemap`

    - ### Methods inherited from class net.sourceforge.jtds.jdbc.TestBase

      `compareInputStreams, compareReaders, connect, dropDatabase, dropFunction, dropProcedure, dropTable, dropTrigger, dropType, dropView, dump, dump, dumpAll, dumpKeys, dumpRow, dumpRow, getConnection, getConnection, makeObjects, makeTestTables, setUp, tearDown`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ResultSetTest

          public ResultSetTest(java.lang.String name)

  - ### Method Detail

    - #### testBug644

          public void testBug644()
                          throws java.lang.Exception

      Test for bug #644, updateNull not working with MSSQL DECIMAL field.
      Throws:
        `java.lang.Exception`

    - #### testAutoIncrement

          public void testAutoIncrement()
                                 throws java.lang.Exception

      Test for bug #690, IS_AUTOINCREMENT invalid for identity columns.
      Throws:
        `java.lang.Exception`

    - #### testGetObject1

          public void testGetObject1()
                              throws java.lang.Exception

      Test BIT data type.
      Throws:
        `java.lang.Exception`

    - #### testGetObject2

          public void testGetObject2()
                              throws java.lang.Exception

      Test TINYINT data type.
      Throws:
        `java.lang.Exception`

    - #### testGetObject3

          public void testGetObject3()
                              throws java.lang.Exception

      Test SMALLINT data type.
      Throws:
        `java.lang.Exception`

    - #### testGetObject4

          public void testGetObject4()
                              throws java.lang.Exception

      Test INT data type.
      Throws:
        `java.lang.Exception`

    - #### testGetObject5

          public void testGetObject5()
                              throws java.lang.Exception

      Test BIGINT data type.
      Throws:
        `java.lang.Exception`

    - #### testDateType

          public void testDateType()
                            throws java.lang.Exception

      Test for the problem reported in feature request #78, columns of type DATE are returned as String.
      Throws:
        `java.lang.Exception`

    - #### testResultSetScroll1

          public void testResultSetScroll1()
                                    throws java.lang.Exception

      Test for bug [961594] ResultSet.
      Throws:
        `java.lang.Exception`

    - #### testResultSetScroll2

          public void testResultSetScroll2()
                                    throws java.lang.Exception

      Test for bug [945462] getResultSet() return null if you use scrollable/updatable.
      Throws:
        `java.lang.Exception`

    - #### testResultSetScroll3

          public void testResultSetScroll3()
                                    throws java.lang.Exception

      Test for bug [1028881] statement.execute() causes wrong ResultSet type.
      Throws:
        `java.lang.Exception`

    - #### testResultSetUpdate1

          public void testResultSetUpdate1()
                                    throws java.lang.Exception

      Test for bug [1008208] 0.9-rc1 updateNull doesn't work.
      Throws:
        `java.lang.Exception`

    - #### testResultSetColumnName1

          public void testResultSetColumnName1()
                                        throws java.lang.Exception

      Test for bug [1009233] ResultSet getColumnName, getColumnLabel return wrong values
      Throws:
        `java.lang.Exception`

    - #### testResultSetMetaData

          public void testResultSetMetaData()
                                     throws java.lang.Exception

      Test for fixed bugs in ResultSetMetaData:
      1. isNullable() always returns columnNoNulls.
      2. isSigned returns true in error for TINYINT columns.
      3. Type names for numeric / decimal have (prec,scale) appended in error.
      4. Type names for auto increment columns do not have "identity" appended.
      5. table names are empty when not using cursors, bug [1833720]
      NB: This test assumes getColumnName has been fixed to work as per the suggestion in bug report [1009233].
      Throws:
        `java.lang.Exception`

    - #### testCursorWarning

          public void testCursorWarning()
                                 throws java.lang.Exception

      Test for bug [1022445] Cursor downgrade warning not raised.
      Throws:
        `java.lang.Exception`

    - #### testCursorFallback

          public void testCursorFallback()
                                  throws java.lang.Exception

      Test that the cursor fallback logic correctly discriminates between "real" sql errors and cursor open failures.

      This illustrates the logic added to fix:
      1. [1323363] Deadlock Exception not reported (SQL Server)
      2. [1283472] Unable to cancel statement with cursor resultset
      Throws:
        `java.lang.Exception`

    - #### testCancelResultSet

          public void testCancelResultSet()
                                   throws java.lang.Exception

      Test for bug [1246270] Closing a statement after canceling it throws an exception.
      Throws:
        `java.lang.Exception`

    - #### testGetByName

          public void testGetByName()
                             throws java.lang.Exception

      Test whether retrieval by name returns the first occurence (that's what the spec requires).
      Throws:
        `java.lang.Exception`

    - #### testMoreThan255Columns

          public void testMoreThan255Columns()
                                      throws java.lang.Exception

      Test if COL_INFO packets are processed correctly for `ResultSet`s with over 255 columns.
      Throws:
        `java.lang.Exception`

    - #### testEmptyInsertRow

          public void testEmptyInsertRow()
                                  throws java.lang.Exception

      Test that `insertRow()` works with no values set.
      Throws:
        `java.lang.Exception`

    - #### testInsertRowVisible

          public void testInsertRowVisible()
                                    throws java.lang.Exception

      Test that inserted rows are visible in a scroll sensitive `ResultSet` and that they show up at the end.
      Throws:
        `java.lang.Exception`

    - #### testUpdateRowDuplicatesRow

          public void testUpdateRowDuplicatesRow()
                                          throws java.lang.Exception

      Test that updated rows are marked as deleted and the new values inserted at the end of the `ResultSet` if the primary key is updated.
      Throws:
        `java.lang.Exception`

    - #### testUpdateRowUpdatesRow

          public void testUpdateRowUpdatesRow()
                                       throws java.lang.Exception

      Test that updated rows are modified in place if the primary key is not updated.
      Throws:
        `java.lang.Exception`

    - #### testDeleteRowMarksDeleted

          public void testDeleteRowMarksDeleted()
                                         throws java.lang.Exception

      Test that deleted rows are not removed but rather marked as deleted.
      Throws:
        `java.lang.Exception`

    - #### testUpdateRowNoChanges

          public void testUpdateRowNoChanges()
                                      throws java.lang.Exception

      Test for bug [1170777] resultSet.updateRow() fails if no row has been changed.
      Throws:
        `java.lang.Exception`

    - #### testCursorFetch

          public void testCursorFetch()
                               throws java.lang.Exception

      Test the behavior of `sp_cursorfetch` with fetch sizes greater than 1.

      Assertions tested:

      - The current row is always the first row returned by the last fetch, regardless of what fetch type was used.
      - Row number parameter is ignored by fetch types other than absolute and relative.
      - Refresh fetch type simply reruns the previous request (it ignores both row number and number of rows) and will not affect the current row.
      - Fetch next returns the packet of rows right after the last row returned by the last fetch (regardless of what type of fetch that was).
      - Fetch previous returns the packet of rows right before the first row returned by the last fetch (regardless of what type of fetch that was).
      - If a fetch previous tries to read before the start of the `ResultSet` the requested number of rows is returned, starting with row 1 and the error code returned is non-zero (2).
      Throws:
        `java.lang.Exception`

    - #### testAbsoluteMinusOne

          public void testAbsoluteMinusOne()
                                    throws java.lang.Exception

      Test that `absolute(-1)` works the same as `last()`.
      Throws:
        `java.lang.Exception`

    - #### testAbsoluteLargeValue

          public void testAbsoluteLargeValue()
                                      throws java.sql.SQLException

      Test that calling `absolute()` with very large positive values positions the cursor after the last row and with very large negative values positions the cursor before the first row.
      Throws:
        `java.sql.SQLException`

    - #### testRelativeLargeValue

          public void testRelativeLargeValue()
                                      throws java.sql.SQLException

      Test that calling `absolute()` with very large positive values positions the cursor after the last row and with very large negative values positions the cursor before the first row.
      Throws:
        `java.sql.SQLException`

    - #### testUnicodeStream

          public void testUnicodeStream()
                                 throws java.lang.Exception

      Test that `read()` works ok on the stream returned by `ResultSet.getUnicodeStream()` (i.e. it doesn't always fill the buffer, regardless of whether there's available data or not).
      Throws:
        `java.lang.Exception`

    - #### testMaxRows

          public void testMaxRows()
                           throws java.lang.Exception

      Check whether `Statement.setMaxRows()` works okay, bug [1812686].
      Throws:
        `java.lang.Exception`

    - #### testCursorMaxRows

          public void testCursorMaxRows()
                                 throws java.lang.Exception

      Test that `Statement.setMaxRows()` works on cursor `ResultSet`s.
      Throws:
        `java.lang.Exception`

    - #### testSetObjectScale

          public void testSetObjectScale()
                                  throws java.lang.Exception

      Test for bug [1075977] `setObject()` causes SQLException.

      Conversion of `float` values to `String` adds grouping to the value, which cannot then be parsed.

      Throws:
        `java.lang.Exception`

    - #### testCursorPrevious

          public void testCursorPrevious()
                                  throws java.lang.Exception

      Test that `ResultSet.previous()` works correctly on cursor `ResultSet`s.
      Throws:
        `java.lang.Exception`

    - #### testOutOfMemory

          public void testOutOfMemory()
                               throws java.sql.SQLException

      Test the behavior of the ResultSet/Statement/Connection when the JVM runs out of memory (hopefully) in the middle of a packet.

      Previously jTDS was not able to close a ResultSet/Statement/Connection after an OutOfMemoryError because the input stream pointer usually remained inside a packet and further attempts to dump the rest of the response failed because of "protocol confusions".
      Throws:
        `java.sql.SQLException`

    - #### testRelative

          public void testRelative()
                            throws java.lang.Exception

      Test for bug [1182066] regression bug resultset: relative() not working as expected.
      Throws:
        `java.lang.Exception`

    - #### testUpdateRowPosition

          public void testUpdateRowPosition()
                                     throws java.lang.Exception

      Test that after updateRow() the cursor is positioned correctly.
      Throws:
        `java.lang.Exception`

    - #### testUpdateableClientCursor

          public void testUpdateableClientCursor()
                                          throws java.lang.Exception

      Test for bug [1197603] Cursor downgrade error in CachedResultSet -- updateable result sets were incorrectly downgraded to read only forward only ones when client side cursors were used.
      Throws:
        `java.lang.Exception`

    - #### testDistinctBug

          public void testDistinctBug()
                               throws java.lang.Exception

      Test bug with Sybase where readonly scrollable result set based on a SELECT DISTINCT returns duplicate rows.
      Throws:
        `java.lang.Exception`

    - #### testPessimisticConcurrency

          public void testPessimisticConcurrency()
                                          throws java.lang.Exception

      Test pessimistic concurrency for SQL Server (for Sybase optimistic concurrency will always be used).
      Throws:
        `java.lang.Exception`

    - #### testDynamicCursors

          public void testDynamicCursors()
                                  throws java.lang.Exception

      Test if dynamic cursors (`ResultSet.TYPE_SCROLL_SENSITIVE+1`) see others' updates. SQL Server only.
      Throws:
        `java.lang.Exception`

    - #### testZeroFetchSize

          public void testZeroFetchSize()
                                 throws java.lang.Exception

      Test for bug [1232733] setFetchSize(0) causes exception.
      Throws:
        `java.lang.Exception`

    - #### testRowstat

          public void testRowstat()
                           throws java.lang.Exception

      Test for bug [1329765] Pseudo column ROWSTAT is back with SQL 2005 (September CTP).
      Throws:
        `java.lang.Exception`

    - #### testConcurrentResultSets

          public void testConcurrentResultSets()
                                        throws java.lang.Exception

      Test for bug [2051585], TDS Protocol error when 2 ResultSets on the same connection are being iterated at the same time.
      Throws:
        `java.lang.Exception`

    - #### array2String

          private static java.lang.String array2String(java.lang.Object[] a)

    - #### testNumericOverflow

          public void testNumericOverflow()
                                   throws java.sql.SQLException

      Test for bug [1855125], numeric overflow not reported by jTDS.
      Throws:
        `java.sql.SQLException`

    - #### testNegativeOverflow

          public void testNegativeOverflow()
                                    throws java.sql.SQLException

      Test for bug [2860742], getByte() causes overflow error for negative values.
      Throws:
        `java.sql.SQLException`

    - #### testDatePerformance

          public void testDatePerformance()
                                   throws java.sql.SQLException

      Test for bug #548, Select statement very slow with date parameter.
      Throws:
        `java.sql.SQLException`

    - #### main

          public static void main(java.lang.String[] args)

Generated on June 8 2013