Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6334998

DataSet methods throws SQLException instead of SQLRuntimeException

XMLWordPrintable

    • b59
    • generic
    • generic
    • Verified

      JDK : 1.6-b54
      DB : orcl, mssql
      Platform[s] : solaris, windows, linux

      All of the DataSet methods that are supposed to be throwing SQLRuntimeException (according to the API spec), throw SQLException instead and require that SQLException must be caught or thrown. They do not yet throw SQLRuntimeException. Code will not compile unless SQLException is caught or thrown.

      Methods:
      ========
      asRowSet()
      getRow()
      insert(T row)
      modify(T row)
      modify()
      delete()
      close()
      isReadOnly()
      isConnected()
      isScrollable()
      getWarnings()
      clearWarnings()

      Sample Code:
      ============
      DataSet rows = mq.getAllMammals();
      Mammal newMammal = new Mammal();
      try {
          rows.insert(newMammal);
      } catch (SQLRuntimeException ex) {
          System.out.println("Error!");
      }

      Output:
      =======
      unreported exception java.sql.SQLException; must be caught or declared to be thrown
                  rows.insert(newMammal);
                             ^
      1 error

            ahandasunw Amit Handa (Inactive)
            jsuensunw Jesse Suen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: