aspose file tools*
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 JavaScript Promises Essentials this week in the JavaScript 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