String s = "kpreddy"; String query = "SELECT UserId FROM Security WHERE UserId =" + s; PreparedStatement stmt = dbconn.prepareStatement(query); ResultSet rs = stmt.executeQuery(); When I run this queary I get too few parameters. Please tell me how to pass a host variable to select queary. Thanks In Advance. Pratap
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
if you are building a SQL statement it has to be well formed. The result you will get will look like: SELECT UserId FROM Security WHERE UserId =kpreddy kpreddy has to be in quotes! You need to do something like: String query = "SELECT UserId FROM Security WHERE UserId ='" + s + "'";
Hi Thomas Paul, With you suggestion I changed accordingly but this different error message "Column not Found". But I tried using dynamic SQl as follows it is working fine.
Using the above method I am able to get my requirements. But Thanks for Help.