Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What Would Cause A Method That Inserts Records To Throw An Exception?

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use the MySQL database and the Tomcat 4.1.18 web server. I try to insert a record to a table message_thread in the MySQL database. The first column of that table is for the ID of each recored. I created that column (field) with INTEGER AUTO_INCREMENT. Therefore, I did not mention that field in the method that inserts records. I got an internal server error and the root cause is:

[ January 05, 2004: Message edited by: JiaPei Jen ]
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try changing "stmt.execute();" to "stmt.executeUpdate();". Small difference, but I've seen some driver implementations flub the execute method. Besides, you're doing an insert anyways, so use the appropriate executeUpdate method!
This may not be the cause, but it's an easy check.
Jamie
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have changed the statement to:

The error message is the same.
Let me ask this -- if we try to insert a null into a field that is defined as "NOT NULL", will we get an error message saying "trying to insert a null value into a field that is not supposed to be a null"? or an exception is thrown to us like what I got?
 
m bhramaresh
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just check in the database whether to the field u r entering the null value is a not null field like it might be declared as a primary key,
just check this thing, just intimate if it is solved prior.
thnx
bhramaresh
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic