• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

SQL Error!!

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys!
I have a sql query which inserts a record in a table in a MSSQL database. This table has its primary key column as autoincrement. Obviously, I don't mention about the autoincrement column while inserting data. i.e. the 'executeUpdate' query will have all the column names and values except this autoincrement column(in this case the column name is messageID and table name is tDiscussion). This code works perfectly fine at my office. It gives problem when hosted on a different server. At both sides the server running the JSP pages is TOMCAT. I will write my query below and the error under it. Please... help.
QUERY:
String query="INSERT INTO tDiscussion(parent,subject,name,email,date,message,category)"
+"VALUES ('0','"+subject+"','"+name+"','"+email+"','"+datee+"','"+message+"','"+category+"')";

ERROR:
Internal Servlet Error:
javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value NULL into column 'messageID', table 'photo.photo.tDiscussion'; column does not allow nulls. INSERT fails.
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll bet the version of the jdbc driver for the MS/SQL implementation is different on each machine.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using the same database in each case, and if not, did you double-check that the primary key is really an identity column in the second database?
- Peter
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic