File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Prepared Statement Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Prepared Statement Problem" Watch "Prepared Statement Problem" New topic
Author

Prepared Statement Problem

Ross Howard Miller
Greenhorn

Joined: Jan 23, 2012
Posts: 11
I'm getting a SQLException invalid column index.


James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5

Hi Ross

On what line is this exception being thrown?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Why do you have those quotes around the parameter marker in the SQL?
Michael Dirks
Greenhorn

Joined: May 22, 2006
Posts: 4
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

Joined: Nov 10, 2011
Posts: 11

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();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Prepared Statement Problem