This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Prepared Statement Problem

 
Ross Howard Miller
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting a SQLException invalid column index.


 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ross

On what line is this exception being thrown?
 
Paul Clapham
Sheriff
Pie
Posts: 20177
25
MySQL Database
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you have those quotes around the parameter marker in the SQL?
 
Michael Dirks
Greenhorn
Posts: 4
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're putting quotes around your parameter which means that instead of the query trying to find the row number where call_no_display = callNumber, it's trying to find a case where call_display equals a string that has a question mark in it.

try this instead:
String getRowNumber = "SELECT row_number FROM call_no_browse WHERE call_no_display = ? ";
 
sarath j nair
Greenhorn
Posts: 11
Chrome Eclipse IDE Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You Should get this Error " getting a SQLException invalid column index. " because Its not a proper Query


sql="insert into OTEMPLOYEE(ADMIN) values(?)";
PreparedStatement ps=null;
ps=con.prepareStatement(sql);
ps.setInt(1, admin);
ps.close();
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic