f



SQL ERROR while executing the code java.sql.SQLException: ORA-01008: not all variables bound

Hi all
i'm getting the above error
plz tell me how to solve that error
the code snippet is as bellow

	while(rst.next()){
				con1=DriverManager.getConnection(url2,"rcxdev1","rcxdev1");
	    		PreparedStatement pstmt=null;
	      		pstmt=con1.prepareStatement(sb.toString());
	      		for(int i=0;i<mp.size();i++){

			if((mp.get(rst.getMetaData().getColumnLabel(i+1)).equals("NUMBER")))
	      					{
	      				pstmt.setInt(i+1,rst.getInt(i+1));
	      				System.out.println("number "+i+" "+rst.getInt(i+1));
	      				}

			if((mp.get(rst.getMetaData().getColumnLabel(i+1)).equals("VARCHAR2")))
  					{
  				pstmt.setString(i+1,rst.getString(i+1));
  				System.out.println("char2 "+i+" "+rst.getString(i+1));
  				}

		if((mp.get(rst.getMetaData().getColumnLabel(i+1)).equals("DATE")))
  					{
	      				pstmt.setDate(i+1,rst.getDate(i+1));
	      				System.out.println("date "+i+" "+rst.getDate(i+1));
  					}

		if((mp.get(rst.getMetaData().getColumnLabel(i+1)).equals("CHAR")))
					{
      				pstmt.setString(i+1,rst.getString(i+1));
      				System.out.println("char");
					}
	      		}

	      		pstmt.executeUpdate(sb.toString());
	      		pstmt.close();
			}
			con1.close();
			
				}catch(Exception e){
					e.printStackTrace();
				}

0
mahesh2425 (18)
12/11/2006 1:29:37 PM
comp.lang.java.programmer 52714 articles. 1 followers. Post Follow

2 Replies
860 Views

Similar Articles

[PageSpeed] 24

Hi,

The error says that your SQL-Statement (which you did not post) has some 
variables (like "select * fom table where id=?") and that the variables 
are not set (via pstmt.setXYZ(...)).

Try debugging your code! :-)

Ciao,
Ingo

0
ihomann_spam (405)
12/11/2006 1:35:36 PM
mahesh wrote:
> Hi all
> i'm getting the above error
> plz tell me how to solve that error
> the code snippet is as bellow
>
> 	while(rst.next()){
> 				con1=DriverManager.getConnection(url2,"rcxdev1","rcxdev1");
> 	    		PreparedStatement pstmt=null;
> 	      		pstmt=con1.prepareStatement(sb.toString());
> 	      		for(int i=0;i<mp.size();i++){
>
> 			if((mp.get(rst.getMetaData().getColumnLabel(i+1)).equals("NUMBER")))
> 	      					{
> 	      				pstmt.setInt(i+1,rst.getInt(i+1));
> 	      				System.out.println("number "+i+" "+rst.getInt(i+1));
> 	      				}
>
> 			if((mp.get(rst.getMetaData().getColumnLabel(i+1)).equals("VARCHAR2")))
>   					{
>   				pstmt.setString(i+1,rst.getString(i+1));
>   				System.out.println("char2 "+i+" "+rst.getString(i+1));
>   				}
>
> 		if((mp.get(rst.getMetaData().getColumnLabel(i+1)).equals("DATE")))
>   					{
> 	      				pstmt.setDate(i+1,rst.getDate(i+1));
> 	      				System.out.println("date "+i+" "+rst.getDate(i+1));
>   					}
>
> 		if((mp.get(rst.getMetaData().getColumnLabel(i+1)).equals("CHAR")))
> 					{
>       				pstmt.setString(i+1,rst.getString(i+1));
>       				System.out.println("char");
> 					}
> 	      		}
>
> 	      		pstmt.executeUpdate(sb.toString());
> 	      		pstmt.close();
> 			}
> 			con1.close();
>
> 				}catch(Exception e){
> 					e.printStackTrace();
> 				}


It would be been wise to provide us with the value of 'sb.toString()',
which forms your prepared statement, as without that, we only have 1/2
of the picture... however...

I would say that the problem is either...

A) Your prepared statement has more than 1 unknown (? characters)

B) (more likely) that 'mp.get(rst.getMetaData().getColumnLabel(i+1)'
does not equal "NUMBER", "VARCHAR2", "DATE" or "CHAR" and therefore,
the code is not entereing any of the if statements and the PS variable
is never being set. Try printing out the value of this expression to
discover its true value.

0
12/11/2006 1:41:06 PM
Reply: