I am currently learning JDBC and can successfully query and retrieve data from a MysQL database. But I would like to run this as a method and return the resultset rows from the method to the calling program.
So far I think I have made an appropriate method but am stuck returning the resultset as an object. Eclipse gives me the following error for the return type:
Object cannot be resolved to a type
Here is the method:
public object getAllPosts(int catID) throws Exception{
try{
this.catID = catID;
sql = "SELECT post_id, post_title, post_content, post_date FROM crm_posts WHERE cat_id = ? LIMIT ?";
prep = conn.prepareStatement(sql);
prep.setInt(1, catID);
prep.setInt(2, 3);
// execute statement
rs = prep.getResultSet();
} catch(Exception e){
e.printStackTrace();
}
return rs;
}
What is the return type I should use or is there a better way of doing this?
EDIT:
As stated in the comments it was a (annoying) typo. Object with a capital O.
objectin return type. It should beObjectResultSet.