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

Cannot use recordSet.insertRow on table names including the characters "UNION"

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 6u43
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      When inserting a row into a table which includes the word "UNION" in its title. Another query is sometimes created to count the records in the table. This created query removes the word "UNION" thereby creating an illegal table name and failing. This will presumably fail with other key words. The word "UNION" doesn't have to be capitalized because the SQL statement is capitalized.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create an empty table with the word Union in its name in Microsoft Access.
      Create an updatable RecordSet.
      Insert a new row.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      SqlException Syntax Error in From Clause/cannot find table
      ACTUAL -
      SqlException Syntax Error in From Clause/cannot find table

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public static void main(String[] args) throws SQLException, ClassNotFoundException {
      String filename="C:\\Users\\Phil\\Documents\\Test\\AddressManagement.accdb";
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=";
      database+= filename.trim(); // add on to the end
      Connection c = DriverManager.getConnection( database );
              //Connection c = DriverManager.getConnection("jdbc:derby:foo_test;create=true");
              Statement s = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);

              try {
                  s.executeUpdate("DROP TABLE testuniontable");
              } catch (SQLException e) {
              }

              s.executeUpdate(
                  "CREATE TABLE testuniontable " +
                  "(ikey INTEGER )");
              
              s.close();
              s=c.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
              ResultSet rowset = s.executeQuery("SELECT * FROM testuniontable");
              rowset.moveToInsertRow();
              rowset.updateLong(1, 1);
              rowset.insertRow();

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Change table name

        Attachments

          Activity

            People

            Assignee:
            lancea Lance Andersen
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: