This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQL Exception: Invalid Handle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Exception: Invalid Handle" Watch "SQL Exception: Invalid Handle" New topic
Author

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=?";

synchronized(seleStmt)
{
seleStmt.clearParameters();
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: http://aspose.com/file-tools
 
subject: SQL Exception: Invalid Handle
 
Similar Threads
[urgent] need help on interceptor and suspending threads
SQL Exception : Invalid Handle
[Urgent] need help on Lock and Condition
error in compling --can anyone help
RequestDispatcher.forward problem