0

Derby is throwing exception with code 42802. It seems, this particular piece of code is source of trouble, but I can not see why.

if(!resultSet.next())
        {
            statement=connection.prepareStatement("CREATE TABLE "+TABLE_NAME+"("+
                    "ID varchar(100) primary key,\n"+
                    "TITLE varchar(100),\n"+
                    "AUTHOR varchar(100),\n"+
                    "ISBN varchar(100),\n"+
                    "PUBLISHER varchar(100),\n"+
                    "PUBLISHED_YEAR varchar(100))"
            );
        }
        else
        {
             statement = connection.prepareStatement(INSERT INTO BOOKS VALUES ('A', 'A', 'A', 'A', 'A', 'A'));
             statement.execute();
        }

1 Answers1

0

Error 42802 is "The number of values assigned is not the same as the number of specified or implied columns."

See https://db.apache.org/derby/docs/10.4/ref/rrefexcept71493.html

Now the number of values (6) in your INSERT seems to match the number of columns declared by the CREATE TABLE. However, that doesn't mean that the actual table structure matches that CREATE TABLE code. Check the actual table structure for the BOOKS table.

See how to describe and show table in DERBY DB?

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216