Knute Snortum wrote:Do you need a closing paren ")" after tutorSubjects?
Paul Clapham wrote:Sorry, but that line of code can't possibly throw the exception you told us about. It would be more useful if you showed us the actual stack trace (copy and paste it) along with the actual code leading up to where the exception occurred. Copy and paste that too.
Knute Snortum wrote:I'd try:
INSERT INTO hi5project.tutor (...
space between hi5project.tutor and (
Knute Snortum wrote:Is the column tutorAge really a String? If it's an int, then setString() will cause an error.
Dave Tolls wrote:This looks like a webapp, in which case your use of statics inside the DAO is not going to be threadsafe.
You could well end up with two request attempting to use the same connection/statement etc at the same time.
Indeed, you could end up with a query starting with one connection, only to find it closed before it is finished.
Dave Tolls wrote:Don't make them static.
Indeed, don't have them as instance variables at all.
Your DAO methods should:
1. get a connection from a connection pool (you shouldn't be creating new connections each time).
2. create your PreparedStatement object and execute it.
3. close everything.
Note that (3) is usually part of a try-with-resources thing:
(note the above may have syntax issues as I just wrote it directly)
Dave Tolls wrote:MySQLIntegrityConstraintViolationException: Column 'tutorName' cannot be null
That's saying you are trying to put a null value into that column, and the column is marked as NOT NULL.
tangara goh wrote:
How can it be a null value when I have filled up all the required fields in the form ? I have entered a name into the textbox for Name.
I did not leave any part of the fields empty.
Swastik Dey wrote:
Check what you are getting in variable name. Is it null?