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

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 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
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
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
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
range of int in c
range of int in c  What is the range of int in c/c++ and Java programming language
date range in sql
date range in sql  How can I select a random date from a date range in SQL server
Mysql Btree Index
Mysql Btree Index  Mysql BTree Index Which tree is implemented to btree index? (Binary tree or Bplus tree or Bminus tree
ModuleNotFoundError: No module named 'range'
ModuleNotFoundError: No module named 'range'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'range' How to remove the ModuleNotFoundError: No module named 'range'
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
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
index
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
Generating random numbers in a range with Java
Generating random numbers in a range with Java  Generating random numbers in a range with Java
the number of parameters
the number of parameters  How do I find out the number of parameters passed into function
rename index in elasticsearch
rename index in elasticsearch  How to rename index in elasticsearch? I have an index with millions of records in it. I want to rename this index... is the command to rename index in elasticsearch? I am using Elasticsearch 6.1. 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
clustered and a non-clustered index?
clustered and a non-clustered index?  What is the difference between clustered and a non-clustered index
ModuleNotFoundError: No module named 'print_range'
ModuleNotFoundError: No module named 'print_range'  Hi, My Python... 'print_range' How to remove the ModuleNotFoundError: No module named 'print_range' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'range-coder'
ModuleNotFoundError: No module named 'range-coder'  Hi, My Python... 'range-coder' How to remove the ModuleNotFoundError: No module named 'range-coder' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'range-regex'
ModuleNotFoundError: No module named 'range-regex'  Hi, My Python... 'range-regex' How to remove the ModuleNotFoundError: No module named 'range-regex' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'range_utils'
ModuleNotFoundError: No module named 'range_utils'  Hi, My Python... 'range_utils' How to remove the ModuleNotFoundError: No module named 'range_utils' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'semver_range'
ModuleNotFoundError: No module named 'semver_range'  Hi, My Python... 'semver_range' How to remove the ModuleNotFoundError: No module named 'semver_range' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'array-range'
ModuleNotFoundError: No module named 'array-range'  Hi, My Python... 'array-range' How to remove the ModuleNotFoundError: No module named 'array-range' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'date_range'
ModuleNotFoundError: No module named 'date_range'  Hi, My Python... 'date_range' How to remove the ModuleNotFoundError: No module named 'date_range' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'array-range'
ModuleNotFoundError: No module named 'array-range'  Hi, My Python... 'array-range' How to remove the ModuleNotFoundError: No module named 'array-range' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'port-range'
ModuleNotFoundError: No module named 'port-range'  Hi, My Python... 'port-range' How to remove the ModuleNotFoundError: No module named 'port-range' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'python3-seco-range'
ModuleNotFoundError: No module named 'python3-seco-range'  Hi, My... named 'python3-seco-range' How to remove the ModuleNotFoundError: No module named 'python3-seco-range' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'python3-seco-range'
ModuleNotFoundError: No module named 'python3-seco-range'  Hi, My... named 'python3-seco-range' How to remove the ModuleNotFoundError: No module named 'python3-seco-range' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'range_set'
ModuleNotFoundError: No module named 'range_set'  Hi, My Python... 'range_set' How to remove the ModuleNotFoundError: No module named 'range... have to install padas library. You can install range_set python with following
ModuleNotFoundError: No module named 'range_test'
ModuleNotFoundError: No module named 'range_test'  Hi, My Python... 'range_test' How to remove the ModuleNotFoundError: No module named 'range_test' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'seco-range'
ModuleNotFoundError: No module named 'seco-range'  Hi, My Python... 'seco-range' How to remove the ModuleNotFoundError: No module named 'seco-range' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'time-range'
ModuleNotFoundError: No module named 'time-range'  Hi, My Python... 'time-range' How to remove the ModuleNotFoundError: No module named 'time-range' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'unified-range'
ModuleNotFoundError: No module named 'unified-range'  Hi, My... 'unified-range' How to remove the ModuleNotFoundError: No module named 'unified-range' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'extended_range'
ModuleNotFoundError: No module named 'extended_range'  Hi, My... named 'extended_range' How to remove the ModuleNotFoundError: No module named 'extended_range' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'float_range'
ModuleNotFoundError: No module named 'float_range'  Hi, My Python... 'float_range' How to remove the ModuleNotFoundError: No module named 'float_range' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'ip-range'
ModuleNotFoundError: No module named 'ip-range'  Hi, My Python...-range' How to remove the ModuleNotFoundError: No module named 'ip-range... to install padas library. You can install ip-range python with following
Version of com.albertoquesada>multi-range dependency
List of Version of com.albertoquesada>multi-range dependency
ModuleNotFoundError: No module named 'index'
ModuleNotFoundError: No module named 'index'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'index' How to remove the ModuleNotFoundError: No module named 'index'
ModuleNotFoundError: No module named 'index'
ModuleNotFoundError: No module named 'index'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'index' How to remove the ModuleNotFoundError: No module named 'index'

Ads