• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Error Message - error code 20000  RSS feed

 
Bob Matthews
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am trying to write a new record to an Apache derby database tab;e and I get the following error message

----- SQLException -----
SQL State: 42802
Error Code: 20000
Message: The number of values assigned is not the same as the number of specified or implied columns.

My code is as follows:-



and the table is defined as follows:-

CREATE TABLE xxxxx(Trading_Date DATE NOT NULL, Trading_Time INT NOT NULL, Class_corr_p VARCHAR(4), Return_corr_p DECIMAL(9,6), Trade_No INT, Profit_Loss DECIMAL(6,2), PRIMARY KEY (Trading_Date, Trading_Time));
 
Tim Cooke
Marshal
Posts: 4051
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code is attempting to insert 6 values but your table has 7 columns.
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does?
Where's the seventh?
I count 6.
 
Tim Cooke
Marshal
Posts: 4051
239
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yes, you might be right. I was counting params within parenthesis without looking at what the terms were.

I'm not familiar at all with Apache Derby but have you tried specifying the column names in the insert statement?
 
Bob Matthews
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I tried your suggestion but unfortunately I get the same error

This error really puzzles me since I can confirm that the table has the same number of columns as the number of variables I am trying to insert ???
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You haven't got two copies of the database have you?

When I see incomprehensible issues like this my first check is to do a thorough search for either extra logins or extra databases I might be accidentally referring to.

Other than that, can you do a DESCRIBE on the table and paste the result here?
Also, can you show the db url used in the code, and compare it with the one you are doing the DESCRIBE on?

This will involve launching the db externally if it's an embedded one.
 
Bob Matthews
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have just run a test to write a new record to the Apachy database with just one field entered

AND I still get the same error

Something is really amiss here !
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!