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:
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
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
Advertisements
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
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
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
JSP Out Object
JSP Out Object  JSP Out Object?   out object denotes... of the object out is jsp.JspWriter. The out object "Javax.servlet.jsp.JspWriter". Methods of out Object: clear() clearBuffer() flush() isAutoFlush() getBufferSize
with out class - Java Beginners
with out class  can we write a program with out a class in core java?if yes,give example
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
PHP PDO Index
Database Objects) is a PHP extension which defines an object-oriented... sqlite2   This is the index page of PDO, following pages will illustrate
JSP implicit object out
of out object is used to return the number of empty bytes in the buffer...JSP implicit object out In this Section, we will discuss about implicit object out & it's methods. Out object denotes the Output stream
Writes the given character into buffer at the given index.
Writes the given character into buffer at the given index. In this tutorial you will see how to write the given character into buffer at the given index. The put (int index, char c) allow to write a character at particular index
Writes the given double value into a buffer at the given index.
Writes the given double value into a buffer at the given index. In this tutorial you will see how to write the given double into buffer at the given index. The put (int index, double d) allow to write a character at particular index
JAVA image zoom in/out - Framework
JAVA image zoom in/out  how to write function in java for image zoom in and zoom out using jFreeChart?  Hi Friend, Try the following...); XYSeries series = new XYSeries("Marks"); series.add(1, 80); series.add(2
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
List out different arguments in PHP header function?
List out different arguments in PHP header function?   List out different arguments in PHP header function
Write a long value at given index into long buffer.
. 44645669 57554776 77557434 After putting value at index : 1 Value in buffer...Write a long value at given index into long buffer.  In this tutorial, we will see how to write a long value at given index into long buffer
fill out forms on web pages - JDBC
fill out forms on web pages    I want to fill out forms on web... www.blauh...com , in which there wil be a form , what i hav to do is to fill that form... to the id that has been entered by the user. 1)id.jsp: Enter ID
Photoshop Photo Effects Stand Out Tutorial
org.htmlparser.util.ParserException: C:\downloadingarticles\websitereader\Make dark text stand out on dark pictures (The system cannot find the file specified
Find Character form String example
in the string. The first character index position is 0.  String provide charAt() method to find out the character in the string with the help of index position...:String = "Brijesh"; for (var index:int = 0; index <
Log out from website - JSP-Servlet
="1" width="100%" cellpadding="0" cellspacing...Log out from website  what is the code to how to log out from...;</head><body><table border="1" width="30%"
List with out duplicates - Java Interview Questions
List with out duplicates   Hi all, Naturally in java a list will allow duplicates, but if i want the list which shouldn't allow duplicates then what should be the logic? Thanks in advance abhee  Hi friend
StringValidator in Flex4
StringValidator in Flex4: The StringValidator class validates a string Which is in a specified range or not. You can set the minimuum and maximun range by using minLength and maxLength property. The tag of StringValidator is <
Write a byte into byte buffer at given index.
Write a byte into byte buffer at given index.  In this tutorial, we...; index. ByteBuffer API: The java.nio.ByteBuffer class extends... ByteBuffer putChar(int index, byte b) The putChar(..) method write
jQuery 'Tab Slide Out' Plug-in
jQuery 'Tab Slide Out' Plug-in In this Section, you will learn how to develop a slide out tab using jQuery plug-in. For developing slide out window we are using "jquery.tabSlideOut.v1.3.js" plug-in. The slide out
Take print out from printer at client machienusing jsp - JSP-Servlet
Take print out from printer at client machienusing jsp  Sir/Mam I want do is to take out print out of my report which will be created from the Mysql database with out displaying him/her the results or report from the printer
Write a float value into float buffer at given index.
Write a float value into float buffer at given index.  In this tutorial...;given index. FloatBuffer API: The java.nio.FloatBuffer class extends.... abstract  FloatBuffer put(int index, float f) The put
Write a int value into int buffer at given index.
Write a int value into int buffer at given index.  In this tutorial, we...;index. IntBuffer API: The java.nio.IntBuffer class extends.... abstract  InttBuffer put(int index, int value) The put(..) method write
How to get specific index value from int buffer.
IndexValue Value at index 0 : 7 Download this code...How to get specific index value from int buffer. In this tutorial, we will discuss how  to get specific index value from int buffer. IntBuffer
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
How to get given index value from FloatBuffer in java.
How to get given index value from FloatBuffer in java.  In this tutorial, we will discuss how to get given index value from FloatBuffer in java... value at current position and increment the position by 1
ShortBuffer in java, Write a short value into short buffer at given index.
Put value at index . 2 Content in short buffer. 1 2 655 4 5 Download...Write a short value into short buffer at given index.  In this tutorial...;given index. ShortBuffer API: The java.nio.ShortBuffer class extends
'append' & 'fade out/in' on mouse hover
'append' & 'fade out/in' on mouse hover In this tutorial, we will discuss about how to apply 'append' & 'fade out/in'...; is appended on it & it will fade out/in to show mouse pointing. The fadeout is set
How to get specific index value from long buffer.
643564 Long value in buffer at given index 1. 8765433 Download this code...How to get specific index value from long buffer. In this tutorial, we will discuss how  to get specific index value from long buffer. LongBuffer
For printing out strings, there are echo, print and printf. Explain the differences.
For printing out strings, there are echo, print and printf. Explain the differences.  For printing out strings, there are echo, print and printf. Explain the differences
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx  Write a program that will print out a hydro bill. The bill... will be entered by the user: - Account number (12 digit code) - Address - Kilowatts used
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx  Write a program that will print out a hydro bill. The bill... will be entered by the user: - Account number (12 digit code) - Address - Kilowatts used
write file in aplication folder with out giving full path - WebSevices
write file in aplication folder with out giving full path  i have a simple java class by the help of this java class i want to write file in application folder with out giving full path like c:/data/aa
How to get specific index value from ByteBuffer in java.
How to get specific index value from ByteBuffer in java.    ... will discuss how to get value of a given index from buffer. The ByteBuffer class is a container for handling data. The get(int index) method of ByteBuffer
How to get specific index value from short buffer.
How to get specific index value from short buffer. In this tutorial, we will discuss how  to get specific index value from short buffer. ShortBuffer...; abstract short get( int index) The get() method reads is short
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
calling java method from html form with out using javascript - JSP-Servlet
(TempChar, 0)==-1) return (false); } return (true);}<...calling java method from html form with out using javascript  How can...) { TestVar = isNumberString(form.inputbox.value) if (TestVar == 1) alert ("
NumberValidator in Flex4
NumberValidator in Flex4: The NumberValidator class validates a  number. You can specify the minimum and maximum range of value by using the minValue and maxValue property. You can specify the domain property for integer value
can we mark the class with abstract..with out having any mothed in tit as abstract!!! - Java Beginners
can we mark the class with abstract..with out having any mothed in tit as abstract!!!  hi, can we wite an calls without any abstract methods in it  Hi Friend, No, you can't create abstract class without abstract
Count Palindromes from the string
Count Palindromes from the string In this section, we are going to find out the number of palindromes from the string. For this, we have allowed the user... by ignoring cases. If they are same, the counter will count the number
Adobe Flex Component Index
can put validations on different field so easily and effectively. Index of Flex
String length property example
in Action Script3:- If user want to find out number of characters in a string. In this case String has a length property that return the number of characters... is 0. Example:- <?xml version="1.0" encoding="
JSP Arraylist Index
and value to the postindex.jsp, which take all values and placed into the ArrayList..." method="POST"> <table border="1"> <... border="1"> <thead> <tr> <th>Index</th>
 

 

 

DMCA.com