Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet error:Parameter index out of range (1 > number of parameters, which is 0).
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


akanksha
error:Parameter index out of range (1 > number of parameters, which is 0).
2 Answer(s)      a year and 8 months ago
Posted in : JSP-Servlet


my code:String org=request.getParameter("Org"); String desg=request.getParameter("des"); String From=request.getParameter("From"); String To=request.getParameter("To"); String expdetail=request.getParameter("expdetail"); System.out.println(org); String sqlOption1="Insert into experience(candidateid,org,desg,from,to,expdetail) select * from candidate where candidateid in(select max(candidateid) from candidate)"; String sqlOption2="select candidateid from candidate"; ps1=conn.prepareStatement(sqlOption1); rs=ps1.executeQuery(sqlOption2); System.out.println(ps1); while(rs.next()) { c=rs.getString("candidateid"); } System.out.println(c); ps1.setString(1,c); ps1.setString(2,org); ps1.setString(3,desg); ps1.setString(4,From); ps1.setString(5,To); ps1.setString(6,expdetail); int x=ps1.executeUpdate();


Advertisement
View Answers

March 7, 2013 at 4:03 PM


hi friend,

You are using PreparedStatement to insert the value. And you are trying to set the value of field using the setXXXX() method of PreparedStatement and in your SQL string you didn't use the ? (question mark) to assign a value. So edit your sql string as follows:

Edit your sql string as INSERT INTO table_name VALUES (?,?,?,?). Number of question mark should be equal to the number of fields in table.

Thanks.



March 7, 2013 at 4:18 PM


you are missing a matching escape

Insert into experience(candidateid,org,desg,from,to,expdetail) select * from candidate where candidateid in(select max(candidateid) from candidate)";

It should be like this

Insert into experience('candidateid', 'org', 'desg', 'from', 'to','expdetail') select * from candidate where candidateid in(select max('candidateid') from candidate)";



Related Tutorials/Questions & Answers:
error:Parameter index out of range (1 > number of parameters, which is 0).
error:Parameter index out of range (1 > number of parameters, which is 0...: Edit your sql string as INSERT INTO table_name VALUES (?,?,?,?). Number of question mark should be equal to the number of fields in table. Thanks.   
Index Out of Bound Exception
is thrown when  a String  object detects an index  out-of-range index. Usually, An string object occurs out-of-range , when the index is less than zero... Index Out of Bound Exception   
Advertisements
write an application that print out the even numbers between the range 100-200
write an application that print out the even numbers between the range 100-200   write an application that print out the even numbers between the range 100-200 ?   The given code accepts the number from 100 to 200
MySQL range
MySQL range       May times the programmer needs to find out some specific data which lies in the particular range of values but there is not any predefined function in MySQL but we
In and Out parameters - SQL
parameters-IN,OUT,INOUT. 1)IN: It is default parameter which is passed...In and Out parameters  What are in and out parameters in stored...)OUT: This parameter does not supply any value to the procedure.It is assumed
How do I find out the number of parameters passed into function9. ?
How do I find out the number of parameters passed into function9. ?  How do I find out the number of parameters passed into function9
Find out the prime number
Find out the prime number      ... to find out whether a given number is prime or not. Here we have used the 'for loop..., a prime number is only divided by 1 and itself, in other words it has no other
What is Index?
What is Index?  What is Index
supplying values to in parameters of stored procedure in ms sql and displaying out parameters
supplying values to in parameters of stored procedure in ms sql and displaying out parameters  I have to execute following procedure ALTER PROCEDURE [dbo].[get_date] @codeId int, @vardate as datetime OUTPUT AS SELECT
Prime Numbers from range
)); while (i>1){ if ((number!=i) && (number%i==0...(); int index1=0; int index2=number.length()-1; char x...; if (index2-index1==0 || index2-index1==1) list.add(i); index1
index of javaprogram
index of javaprogram  what is the step of learning java. i am not asking syllabus am i am asking the step of program to teach a pesonal student.   To learn java, please visit the following link: Java Tutorial
date range in sql
date range in sql  How can I select a random date from a date range in SQL server
range of int in c
range of int in c  What is the range of int in c/c++ and Java programming language
Drop Index
_table(stu_id); Drop Index THE drop index stu_index 1 is used... Drop Index       Drop Index is used to remove one or more indexes from the current database
print the even numbers between the range 100-200
print the even numbers between the range 100-200  Q ?write an application that print out the even numbers between the range 100-200 ? 1- which aer not divisible by 7 and 5 ? 2- Number of the numbers which are not divisible
Mysql Btree Index
Mysql Btree Index  Mysql BTree Index Which tree is implemented to btree index? (Binary tree or Bplus tree or Bminus tree
range of dates in mysql query
range of dates in mysql query  How to select the range of dates in mysql ..when i have to select from between & and of date function?   SELECT * FROM MAAccounts WHERE updatedOn BETWEEN ? AND ? ORDER
NSMutableArray change object at Index
to replace object, it's the best way to do that) for (int index = 0; index <...NSMutableArray change object at Index   NSMutableArray change object at Index   // Browse all messages (you can use "for (NSDictionary
What is the byte range? - Java Beginners
What is the byte range?   Hi, Please tell me range in byte. Thanks   The range is: 128 to 127 Thanks
Which request executed first Out of multiple requests in servlet
Which request executed first Out of multiple requests in servlet  Servlet handles multiple request simultaneously.Every new request will be assigned... to servlet ,which request will be executed first , please correct me if question
Generating random numbers in a range with Java
Generating random numbers in a range with Java  Generating random numbers in a range with Java
find out in servlet which button was clicked on an html page
find out in servlet which button was clicked on an html page  i have two buttons on my jsp page... and i want two call two seperate codes in a servlet on pressing of those 2 buttons.. how do i find out which button was clicked so
clustered and a non-clustered index?
clustered and a non-clustered index?  What is the difference between clustered and a non-clustered index
JavaScript array index of
line. 1)index of( )  - This return the position of the value that is hold...JavaScript array index of  In this Tutorial we want to describe that makes you to easy to understand JavaScript array index of. We are using JavaScript
Drop Index
(stu_id); Drop Index THE drop index stu_index 1 is used... Drop Index       Drop Index is used to remove one or more indexes from the current database
z-index always on top
z-index always on top  Hi, How to make my div always on top using the z-index property? Thanks   Hi, You can use the following code: .mydiv { z-index:9999; } Thanks
Java arraylist index() Function
Java arrayList has index for each added element. This index starts from 0. arrayList values can be retrieved by the get(index) method. Example of Java Arraylist Index() Function import
array, index, string
array, index, string  how can i make dictionary using array...please help
$_GET[] index is not defined
$_GET[] index is not defined  Hi, What could be solution of the error: $_GET['someparameter'] index is not defined Thanks   Hi, You can use the following code: if (isset($_GET['someparameter'])) { // your code
Excel Validating Value in Range
Excel Validating Value in Range In this section, you will learn how to validate a cell's value within a defined range using Apache POI. EXAMPLE... a defined range. Here, defined range is 10 to 100. import
Advertisements
 

 

 

DMCA.com