• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic