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).

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 5 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
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
What is Index?
What is Index?  What is Index
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
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
Dialog Box: Input Range Method
Java NotesDialog Box: Input Range Method  This utility method shows how to read in a loop until a number in a satisfactory range is entered. 1 2 3 4 5 6 7 8 9 10 11 12
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
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
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
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
Mysql Btree Index
Mysql Btree Index  Mysql BTree Index Which tree is implemented to btree index? (Binary tree or Bplus tree or Bminus tree
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
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
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
Generating random numbers in a range with Java
Generating random numbers in a range with Java  Generating random numbers in a range with Java
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
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
the number of parameters
the number of parameters  How do I find out the number of parameters passed into function
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
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
show selected date range in calender
show selected date range in calender  helo, i'm working in a project in jsp. suppose thier are 2 textbox 1.start date 2. end date whatever date selected in these textbox get highlighted in the calendar, please help
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
i am confused here on what to write can some 1 help out here - Java Beginners
i am confused here on what to write can some 1 help out here  i don't quite understand how to code it so can some one help out
$_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
About Dr. Karni Singh Shooting Range Delhi
enjoy in this part of the range. This outdoor range is laid out over a large...The Dr. Karni Singh Shooting Range in Delhi Most people who travel to Delhi may not think that a shooting range is a worthwhile attraction. However
really need help on how to write this program plz some 1 help out. - Java Beginners
really need help on how to write this program plz some 1 help out.  i am confused here on what to write can some 1 help out here i dont quite understand how to code it so can some 1 help out. Part II Write, compile and execute
checking index in prepared statement
checking index in prepared statement  If we write as follows: String query = "insert into st_details values(?,?,?)"; PreparedStatement ps = con.prepareStatement(query); then after query has been prepared, can we check the index
Multiply a range of array elements using Recursion
Multiply a range of array elements using Recursion In this section you will learn how to use recursion to multiply a range of array elements. For this we have... that contains the range of elements to be multiplied, an int specifying the starting
log out
log out  how do i create a log out on a project without it exiting system so it does not reload again
Is there anyone out there?
Is there anyone out there?  Hi please could somebody respond as I am seeking advice but not getting any and do not know whether or not to continue using this site
Programming: Body Mass Index - Dialog
Mass Index (BMI). BMI is a commonly used formula which shows the relationship... Java NotesProgramming: Body Mass Index - Dialog Name.... Display the BMI number along with a message about their weight
Mysql Date Index
combination of columns in a database table. An Index is a database structure which... | PRIMARY | 1 | ID | A | 2 | NULL | | | BTREE | | | userform | 1 | date_index... Mysql Date Index      
creating index for xml files - XML
creating index for xml files  I would like to create an index file for xml files which exist in some directory. Say, my xml file is like below... after another and then retrieve each tag and create index to that file. In some
Java Programming: Chapter 4 Index
. A subroutine consists of the instructions for carrying out a certain task, grouped... necessary to carry out the task associated with that subroutine. Subroutines can... subroutines and then use them to help write more complex subroutines, which can
alter table create index mysql
alter table create index mysql  Hi, What is the query for altering table and adding index on a table field? Thanks
index - Java Beginners
the number of occurrences of the character in the text. Write a Java GUI... of text and uses String method indexOf to determine the total number of occurrences... =0;counter=0;j--){ if(ch==third[j]) flag=true; } if(!flag
Pointing last index of the Matcher
will arrive.":- Declaring text as String in which last index of word Tim...;System.out.println(matcher[0]+index);      m.find();   int ... Pointing last index of the Matcher   
Mysql Time Range
Mysql Time Range      ... Time Range'. To understand example we create a table 'timetable' with fields... | +------------+ | 10:10:10 | +------------+ 1 row in set (0.00
alter table create index mysql
alter table create index mysql  Hi, What is the query for altering table and adding index on a table field? Thanks   Hi, Query is: ALTER TABLE account ADD INDEX (accounttype); Thanks
Advertisements
 

 

 

DMCA.com