Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

: How can i pass the values in string parameters to a stored procedure  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jsp code




servlet code



this is my complete code can you please help me out as i am new to this
 
Bartender
Posts: 598
26
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

kavitha vemula wrote:


Those quotes do not look right. Also, please use placeholders and PreparedStatement, so as not to use Dynamic SQL.

On a side note "I am an intelligent" does not match the other options. To match the others, perhaps it ought to be, "I am an intelligent person".
 
Rancher
Posts: 3385
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the signature of the stored procedure?
That is, its name and parameters and the types of the parameters.

And you will need to use a CallableStatement.
 
kavitha vemula
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Parameters : @fromdate , @Todate,@Users

this is what i did try (CallableStatement s = conn.prepareCall("{CALL Users(@fromdate=?,@Todate=?,@Users=?)}")) {
s.getDate(FromDate);
s.getDate(ToDate);
s.getstring(Users)
try (ResultSet rs = s.executeQuery()) {
rs.next();
System.out.println(rs.getString("response"));
}

this is what i had done
 
Dave Tolls
Rancher
Posts: 3385
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the first thing that leaps out at me is you are using the getXX methods when you want to bet setting the values.
So those need to be changed.

The second thing is that users is an array, not a String, so you'll need to set an array.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!