• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am trying to insert some data using preparedStatement
stringbuffer.append("Insert into testuser(username,email,testname,testdate,");
stringbuffer.append("validityperiod,testid,percentage,message)");
stringbuffer.append("values(?,?,?,'"+s4+"','"+s4+"',?,?,?)");

PreparedStatement preparedstatement = connection.prepareStatement(stringbuffer.toString());

preparedstatement.setString(1, s1);
preparedstatement.setString(2, s2);
preparedstatement.setString(3, s3);
//preparedstatement.setString(4, s4);
//preparedstatement.setString(5, s4);
//preparedstatement.setString(6, s6);
preparedstatement.setInt(6, Integer.parseInt(s6));
//preparedstatement.setString(7, s7);
preparedstatement.setInt(7, Integer.parseInt(s7));
preparedstatement.setString(8, s8);

System.out.println("After insertion");

statement.executeUpdate(stringbuffer.toString());


here s4 is sate like( 05-january-2005)




this is the error appeared at consloe window of tomcat
java.sql.SQLException: ORA-01008: not all variables bound

what might be the problem

please help me...

cinux
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


with this line you have to bind 6 variables.It asks you bind all variables,with indexes 1 to 6.
[ December 05, 2005: Message edited by: sinasi susam ]
 
sinasi susam
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And also you will need to u,execute the method with ;

statement.executeUpdate();

you dont put sql string into method again ,...
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok now i have modified my code to this



stringbuffer.append("Insert into testuser(username,email,testname,testdate,");
stringbuffer.append("validityperiod,testid,percentage,message)");
stringbuffer.append("values(?,?,?,?,?,?,?,?)");

PreparedStatement preparedstatement = connection.prepareStatement(stringbuffer.toString());

preparedstatement.setString(1, s1);
preparedstatement.setString(2, s2);
preparedstatement.setString(3, s3);
preparedstatement.setString(4, s4);
preparedstatement.setString(5, s4);

//preparedstatement.setString(6, s6);
preparedstatement.setInt(6, Integer.parseInt(s6));

//preparedstatement.setString(7, s7);
preparedstatement.setInt(7, Integer.parseInt(s7));
preparedstatement.setString(8, s8);

System.out.println("After insertion");

statement.executeUpdate(stringbuffer.toString());


now also i am getting the saem error


what to do?
 
sinasi susam
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
statement.executeUpdate();
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Saikrishna,

should be

With a prepared statement, you set the SQL string at the beginning when you create the statement. With a regular statement, you pass the SQL when you call an execute method. Since you are passing the SQL when you call executeUpdate(), Java thinks you have a regular statement and doesn't know what to do with the question marks.
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have also tested it by using

preparedstatement.executeUpdate();

but no advantage

is there any other way to insert my values into table???



cinux
 
sinasi susam
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dont give up immediately.

that should work;



do it as it is, it will work.If still not working probably your doing something wrong again.That must work.if your driver supports preparedstatement that it seems it does.
reply
    Bookmark Topic Watch Topic
  • New Topic