This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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.
subject: SQL Exception: Invalid Handle
It's not a secret anymore!