• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySQLIntegrityConstraintViolationException

 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'UserName' cannot be null

is there any problem in my database??

here is the full stack trace ::
 
Tina Smith
Ranch Hand
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that you are calling a procedure/executing sql that sets the value in column "UserName" to null, when the database requires that all values in the column are not null.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4031
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a good example where reading the text of the error message gives you the direction you need to solve the problem.
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah but i am not sending null in UserName from my RegisterAction Bean

i have tested my RegisterAction like

if(UserName == null)
{
return mapping.getInputForward(); // moving the control to final jsp page
}

but the above condition is also not running,, that is my variable UserName in Action bean is not null , and still its showing me the same error in the value of next column
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually you were right..
my variables like User got null in my action bean.. don't know how?

here is my RegisterForm bean


and here is my RegisterAction bean :
 
Prajakta Acharya
Ranch Hand
Posts: 138
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sort of confused looking at your code.
There are 2 variables - name and userName. 'name' is validated for being null and in your action class, 'userName' is being checked for being null.
Which one is actually mapped to JSP? And which one should be checked for validation and in action?
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i am using NetBeans..

and name variable in RegisterForm bean was generated by IDE.. and i have not use it any where in RegisterAction class..

i am using only UserName for Process
 
Prajakta Acharya
Ranch Hand
Posts: 138
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the validation of empty string is done on 'name' parameter.


can you post JSP code as well?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic