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

 
 


akanksha
error:Parameter index out of range (1 > number of parameters, which is 0).
2 Answer(s)      3 months and 15 days 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();

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 Pages:
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   
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
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
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
print the even numbers between the range 100-200
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... prints out the even numbers between the range of 100 and 200 and then determine
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
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
Java Programming: Chapter 11 Index
. This turns out to be a remarkably powerful idea. A subroutine is said...: Section 1: Recursion Section 2: Linking Objects Section 3: Stacks and Queues... | Previous Chapter | Main Index
Java Programming: Chapter 7 Index
a number of new layout managers, component classes, and event types, and we'll see... in this chapter will be used in a number of examples and programming exercises... the rest of this textbook. If you skip it, you will not miss out on any fundamental
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
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   
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
Find Array element from index using GUI
. If the specified index is out of bounds, display the message "Out of Bounds"...]; for(int i=0;i<arr.length;i++){ int x=r.nextInt(100)+1; arr[i]=x...Find Array element from index using GUI In this tutorial, you will learn how
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
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
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
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
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
Drop Index
); Drop Index THE drop index stu_index 1 is used to remove index ... Drop Index       Drop Index is used to remove one or more indexes from the current database
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
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
the number of parameters
the number of parameters  How do I find out the number of parameters passed into function
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
Mysql Time Range
Mysql Time Range      .... Understand with Example The Tutorial illustrate an example from 'Mysql Time Range... | +------------+ 1 row in set (0.00 sec
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
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
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      
Program to display palindrome numbers between some range
); String number=in.toString(); int index1=0; int index2=number.length()-1; char x=number.charAt(index1); char y=number.charAt(index2); while (index2-index1>=0
How do I change the while loop in this code to the range with range list style display page for a resultSet() in jsp?
; <table border="1" width="75%" cellspacing="0" cellpadding="0" bgcolor...="1" width="75%" cellspacing="0" cellpadding="0" bgcolor="#CCFFCC"> <...How do I change the while loop in this code to the range with range list style
including index in java regular expression
including index in java regular expression  Hi, I am using java regular expression to merge using underscore consecutive capatalized words e.g....() > 0) { Pattern p1 = Pattern.compile("\p{Lu}\p{L}+(\s+\p{Lu
Shopping Cart Index Page
Shopping Cart Application What is Shopping Cart ? A shopping cart is an application which runs on the server and allows users to do online shopping. It allows customer to browse catalogue of products from store, add selected items
Java programming 1 - Java Beginners
be at position 1, etc ?A sentence is constructed with a series of words? Index 0 1 2 3 4... of values is outside the possible index range, // i.e. less than 0 or greater than...Java programming 1  write one program, which consists of a main
Java Programming: Chapter 8 Index
-- consisting of a fairly small number of named instance variables -- is just... numbered from zero up to some maximum value, which is set when the array is created..., but it can grow to hold any number of items. Contents of Chapter 8: Section
Java programming 1 - Java Beginners
be at position 1, etc ?A sentence is constructed with a series of words? Index 0...Java programming 1  write one program, which consists of a main...? // in cases where the range of values is outside the possible index range
Java Programming: Chapter 5 Index
(in the form of instance variables) and a number of different tasks or "... of Chapter 5: Section 1: Objects, Instance Methods, and Instance Variables Section... | Previous Chapter | Main Index
Java Programming: Chapter 10 Index
on streams, which are objects that support the same sort of I/O commands that you... with exceptions, which were introduced in the previous chapter. Many of the subroutines...: Section 1: Streams, Readers, and Writers Section 2: Files Section 3: Programming
Java Programming: Chapter 9 Index
robust programs. Contents of Chapter 9: Section 1: Introduction... Chapter | Previous Chapter | Main Index
Java Programming: Chapter 12 Index
of Chapter 12: Section 1: Generic Programming Section 2: List and Set Classes... | Main Index
Java count occurrence of number from array
index = -1; for (int i = 0; i < list2.size(); i++) { if (maxCount <... number: 3 3 2 1 6 4 Number 0 occurs 2... that will count the occurrence of numbers and find the number which has
Java Programming: Chapter 2 Index
, which is sometimes called coding, would then refer to filling in the details...-scale structure. Contents of Chapter 2: Section 1: The Basic Java... | Next Chapter | Previous Chapter | Main Index
Java Programming: Chapter 3 Index
of examples. Contents of Chapter 3: Section 1:Blocks, Loops, and Branches... Chapter | Main Index
Java Programming: Chapter 6 Index
techniques. Contents Chapter 6: Section 1: The Basic Java Applet... [ First Section | Next Chapter | Previous Chapter | Main Index
Foreach loop with negative index in velocity
Current Index: 1Current Index0 Current Index: -1Current... Foreach loop with negative index in velocity  ... with negative index in velocity. The method used in this example
JavaScript array index of
that an array object hold specified by [0]-[3] array indexing followed by break line. 1... JavaScript array index of   ... to easy to understand JavaScript array index of. We are using JavaScript
Spring Constructor arg index
;    <constructor-arg index="0" value...-arg index="1" value="1001" />   <...Constructor Arguments Index In this example you will see how inject
Body Mass Index (BMI)
() method which takes a number and returns a String formatted as requested. See... Java: Body Mass Index (BMI) The Body Mass Index program is divided into two files, the main program
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