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

java.sql.Statement.executeQuery(String sql) shouldnot execute all sql query

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 7u80
    • core-libs
    • x86
    • windows_7

      A DESCRIPTION OF THE REQUEST :
      Currently "java.sql.Statement.executeQuery(String sql)" executes all sql including INSERT, UPDATE & DELETE queries apart from SELECT without any issues.



      JUSTIFICATION :
      When the api promises to return at least one ResultSet, how can it process for INSERT, UPDATE & DELETE queries which don't return any resultSet.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      According to me the api should process only SELECT query. For other types it should throw SQLException.
      ACTUAL -
      "java.sql.Statement.executeQuery(String sql)" executes all sql including INSERT, UPDATE & DELETE queries apart from SELECT without any issues.

      ---------- BEGIN SOURCE ----------
      Statement statement = connection.createStatement();
      ResultSet resultSet = statement.executeQuery(sql);
      ResultSetMetaData rsmd = resultSet.getMetaData();
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      no workaround

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: