*
The moose likes JDBC and the fly likes SQLException : not all variables bound Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLException : not all variables bound" Watch "SQLException : not all variables bound" New topic
Author

SQLException : not all variables bound

Bhavik Patel
Ranch Hand

Joined: Jul 12, 2004
Posts: 155
I am getting SQLException while trying to insert a record in student table

output:
SQLException caught : not all variables bound



ng an Exception while trying to add a record into a database

[edited to add code tags]

[ April 12, 2005: Message edited by: Jeanne Boyarsky ]
[ April 14, 2005: Message edited by: Bear Bibeault ]

SCJP 1.4<br />SCWCD 1.4(91%)<br />Working on SCJD -Bodgitt & Scrapper Constructions...<br /> <br />"It takes 43 muscles to frown & 17 to smile but it doen't take any to just sit there with a dumb look on your face .. Keep Smiling "
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Bhavik,
This line of code is causing the error.


For a prepared statement, you need to call the executeUpdate() method without any parameters.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bhavik Patel
Ranch Hand

Joined: Jul 12, 2004
Posts: 155
Thanks Jeanne....Thank you for pointing out syntax error....i don'tunderstand why i was not getting any syntax error for that statement
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by bhavik patel:
i don'tunderstand why i was not getting any syntax error for that statement


You will not get a syntax error because PreparedStatement interface extends Statement interface, and Statement interface has method executeUpdate(String sql)


thanks


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQLException : not all variables bound
 
Similar Threads
Problem with the query in JDBC ,resultset empty
Sessions in JSF
packages --- Not allowing me to access public class from the same package...
accessing one class from other
java.sql.SQLException: General error