Convert a sqlsessionfactory session.SelectList ArrayList to a Java ResultSet
Hi All, I have been wrecking at this issue for two days now, kindly assist , here is my code below . I'm retrieving a query result from my postgressql database using mybatis. The mybatis part works fine . What i want to do is to be able to printout the elements in the query result to the screen. And I keep getting the error
Exception occurred during event dispatching:
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.sql.ResultSet
at org.elmis.facility.controllers.facilityproductsset upsessionmapperscalls.selectAllFacility_Approved_P roducts(facilityproductssetupsessionmapperscalls.j ava:38)
Code Java:
@SuppressWarnings("unchecked")
public ResultSet selectAllFacility_Approved_Products(){
SqlSession session = sqlSessionFactory.openSession();
try {
ResultSet RSapprovedproducts = (ResultSet) session.selectList("getAllFacilityApprovedProducts");
while (RSapprovedproducts.next()) {
int factypeId = RSapprovedproducts.getInt("facilitytypeid");
int progprodId = RSapprovedproducts.getInt("programproductid");
int id = RSapprovedproducts.getInt("id");
int progId = RSapprovedproducts.getInt("programid");
int prodId = RSapprovedproducts.getInt("productid");
String pcode = RSapprovedproducts.getString("code");
String pname = RSapprovedproducts.getString("primaryname");
int pbeginbal = RSapprovedproducts.getInt("beginningbalance");
int stock = RSapprovedproducts.getInt("stockinhand");
System.out.println(factypeId + " " + progprodId+" "+id +" "+progId+
" " + prodId+ " "+ pcode+" "+ pname+" "+pbeginbal+" "+stock );
}
System.out.println();
System.out.println();
return RSapprovedproducts;
}catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
session.close();
}
return null;
}
Re: Convert a sqlsessionfactory session.SelectList ArrayList to a Java ResultSet
you can't understand what exception is saying ?
Re: Convert a sqlsessionfactory session.SelectList ArrayList to a Java ResultSet
Quote:
Originally Posted by
qazi
you can't understand what exception is saying ?
I understand the exception a bit bear with me this is my first java code project , except , i have no implementation knowledge on how to create a result set from an Array list , I thought a cast would work , but not so. Thanks