• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException in JSP. Inserting Records into Table.

 
Stavan Patel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All, I am still a newbie to Java in general, and i am getting the following error on running this code.




May be i am missing something. this is the code on the page that acts after user fills up a form.
(The database Drivers are installed. I am using Oracle Database 10g Enterprise Edition.)
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35269
383
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stavan,
Welcome to CodeRanch! This is an example where the API is a little tricky until you get used to it.

Look at the difference between these two APIs:


The first one is from the PreparedStatement interface. It is the one you should be using because the SQL was already passed (when creating the prepared statement) and the binding variables already set. You just want to tell Java to "please execute now".

The second one is from the Statement interface. When a statement is created, no SQL is provided up front. Instead you tell Java "please execute this SQL" now.

Since PreparedStatement extends Statement, both are available on the PreparedStatement object. However, your code is telling Java "create a prepared statement and set the binding variables. Then ignore all that and run this sql that includes question marks." Java obliges and then complains about the question marks in the query.
 
Stavan Patel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Jeanne !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic