File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes SQL Exception: Invalid Handle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SQL Exception: Invalid Handle" Watch "SQL Exception: Invalid Handle" New topic

SQL Exception: Invalid Handle

sabbir kazi
Ranch Hand

Joined: Feb 03, 2001
Posts: 62
Getting invalid handle exception for the following code:
private PreparedStatementseleStmt;

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

seleStmt.setString(1, userID);

rsUserID = seleStmt.executeQuery();
System.out.println("execute query OK");
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
you need to add the following statement
seleStmt = connection.prepareStatement(sele);
The SQL statement has to be stored in a PreparedStatement object.

Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
sabbir kazi
Ranch Hand

Joined: Feb 03, 2001
Posts: 62
Thanks Bedi.
I agree. Here's the link:
subject: SQL Exception: Invalid Handle
jQuery in Action, 3rd edition