Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in insert into

 
Sals Hamid
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code:

jsp error: internal servlet error. Syntax error in insert into
I check this code and other code many time but i found no problem but there is problem.Plz help
[ Edited by Dave to add code tags and fix UBB smilies ]
[ February 10, 2002: Message edited by: David O'Meara ]
 
Sean Richards
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in your code you have:
pstm=conn.prepareStatement("INSERT INTO StudentBasic(Name,Address,E-mail,Password,Class) VALUES (???)");

Try using:
PreparedStatment pstm = conn.prepareStatement("INSERT INTO StudentBasic(Name,Address,E-mail,Password,Class) VALUES (?,?,?,?,?)");
This should work.
 
Sals Hamid
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My problem is still not solved???
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sals Hamid:
My problem is still not solved???

Are you sure you need a prepared statement? Try it by using statement1.executeUpdate() and compile your SQL string and show that in the error message, along with what sort of exception it was (SQLException?)
Adam
 
Sals Hamid
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the error
javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
 
Sals Hamid
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can u tell me that syntax of insert into is right or wrong
 
Francois Bourgault
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
VALUES should be declared like this:
VALUES (?,?,?,?,?)
The insert statement is fine, my guess the problem is with the VALUES statement. There's no
',' between each '?'
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic