package com.abc.server;
import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import com.abc.client.modules.beans.AdminBean;
import com.abc.client.modules.beans.ResponseBean;
import com.abc.client.modules.utils.DBPool;
public class AdminServerService {
private Connection con = null;
private DBPool dbPool = new DBPool();
public ResponseBean getAllGroupDetails(int pageSize, int pageNumber) {
ResponseBean dataSet = new ResponseBean();
List<AdminBean> groupDetailsList = new ArrayList<AdminBean>();
ResultSet rs = null;
InputStream in;
CallableStatement cstmt = null;
String driverClass,url = null, username = null,password = null;
try {
in = new FileInputStream("C:\\Users\\vchag\\Desktop\\jdbc.properties");
Properties prop = new Properties();
prop.load(in);
driverClass = prop.getProperty("SQLJDBC.driver");
url = prop.getProperty("SQLJDBC.url");
username = prop.getProperty("SQLJDBC.username");
password = prop.getProperty("SQLJDBC.password");
in.close();
Class.forName(driverClass);
con = DriverManager.getConnection(url, username, password);
cstmt = con.prepareCall(stored procedure name,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
cstmt.setInt("LOGIN_USER_ID",10);
boolean isResultsAvailable = cstmt.execute();
int resultSet = 1;
// Loop through the available result sets.
while (isResultsAvailable) {
rs = cstmt.getResultSet();
if (rs != null) {
if (resultSet == 1) {
while (rs.next()) {
AdminBean result = new AdminBean();
result.setGroupId(rs.getInt(1));
result.setGroupName(rs.getString(2));
groupDetailsList.add(result);
}
dataSet.setGridData(groupDetailsList);
}
}
rs.close();
isResultsAvailable = cstmt.getMoreResults();
resultSet++;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
dbPool.closeAll(rs, cstmt, con);
}
return dataSet;
}
}
I want to iterate over the multiple result sets returned from the stored procedure. When I call the procedure using application with cstmt.execute
it always returns false
even when the result set are available. I am using java 7 and smartgwt 2.6.0 sdk. When I run the same code in a standalone application, it works fine but it doesn't works in my application.