Tuesday, March 27, 2007

java.sql.SQLException: ORA-01008: not all variables bound

One of the cause of this error can be found in the following snippet of code:

query = "select * from AAA where condn = ?";
pstmt = con.prepareStatement(query);
pstmt.setString(1, firstValue);
// ResultSet rs = pstmt.executeQuery(query); // Wrong Usage - Do not provide query again
ResultSet rs = pstmt.executeQuery(); // Correct Usage

Another reason is that you have not mapped all '?' with corresponding values