Heres a class executing PreparedStatements on a Connection.
public class doSomething {
private PreparedStatement ps;
public setPS (Connection conn) throws SQLException {
String sql = "select * from table where id = ?";
ps = conn.prepareStatement(sql);
}
public void runSomething(String var){
ps.setString(1,var);
ResultSet rs = ps.executeQuery();
...
}
}
I call
doSomethingInstance.setPS(conn);
doSomethingInstance.runSomething(var);
from another class and this throws and exception at the
ResultSet rs = ps.executeQuery();
The exception is SQLException: JZ0S4: Cannot execute an empty (zero-length) query. on a Prepared Statement. I cant understand why. Does anyone see what Iam doing wrong here?
Thanks!