Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL Exception: Invalid Handle

 
sabbir kazi
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Getting invalid handle exception for the following code:
private PreparedStatementseleStmt;

private ResultSet rsUserID= null;
String sele = "SELECT * FROM UserData WHERE userID=?";

synchronized(seleStmt)
{
seleStmt.clearParameters();
seleStmt.setString(1, userID);

rsUserID = seleStmt.executeQuery();
System.out.println("execute query OK");
}
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to add the following statement
seleStmt = connection.prepareStatement(sele);
The SQL statement has to be stored in a PreparedStatement object.

 
sabbir kazi
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bedi.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic