Hi All,
i am writing an application in which i am creating web services. i am creating an operation(method) which retrieves database table values from database table in resultset. Hence we can't return resultset value directly in web services. i am creating a class which holds the values from resultset. instead of resultset i am returning object[] of newly created class as follows :
public HistoryInfoByUser[] get_HistoryInfoByUser(@WebParam(name = "email_Id")
String email_Id) throws Exception{
HistoryInfoByUser[] historyIn = null;
if (conn != null) {
CallableStatement cst = conn.prepareCall("{call sp_xxxx(?)}",ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
cst.setString(1, email_Id);
ResultSet resultSet = cst.executeQuery();
int rowCount = resultSet.getRow();
historyIn = new HistoryInfoByUser[rowCount];
while (resultSet.next())
{
historyIn[rowCounter].setId(rowCounter);
historyIn[rowCounter].setStartTime((java.util.Date)resultSet.getObject(1));
historyIn[rowCounter].setType((String) resultSet.getObject(2));
rowCounter++;
}
}
return historyIn;
}
but while trying to access those values in web service client, it is giving java.lang.NullPointerException.
here is the code that i am using in web service client for accessing resultset values :
public void get_HistoryInfoByUser(String email_Id)
{
service = new DBService();
port = service.getDBPort();
try {
List<HistoryInfoByUser> historyIn = port.getHistoryInfoByUser(email_Id);
Iterator iterator = historyIn.iterator();
while (iterator.hasNext()){
System.out.print(iterator.next()+" ");
}
} catch (Exception_Exception ex) {
Logger.getLogger(DataBaseWSHelper.class.getName()).log(Level.SEVERE, null, ex);
}
}
I tried returning a singe row value by returning an object (HistoryInfoByUser) of newly created class instead of object[] (HistoryInfoByUser[] ). It works fine with single object but giving NullPointerException when i am using object[]. i am not getting any way which will help me to overcome with this problem of accessing resultset value.
I thank in advance to your all valuable suggestions which will help me to overcome with this problem.