Hi All,
Really appreciate your help!!!
I am new to java and this is my new project in java.
for my application am trying to get DB results by calling a oracle procedure through JDBC.i was able to do that and was getting results back to the DAO class.am setting those values into bean with setter method,but the problem here is when am trying to retrieve those values in other class using getter method am getting only one value.I can get the values using getter method of bean in the same class that to in the same while loop.
Please help me with this..
public List getTimePeriodDD()throws Exception{
ArrayList weekDD = new ArrayList();
DBConnection dbcon = new DBConnection();
CallableStatement cstmt = null;
LoginForm form = new LoginForm();
ResultSet rs3 = null;
String userId = "";
String periodType = "";
String periodName = "";
String process = "";
int periodValue = 1;
String query = Queries.getQuery();//procedure call
try{
Connection conn = dbcon.getConnection();
cstmt = conn.prepareCall(query);
System.out.println(query);
int j=0;
cstmt.registerOutParameter(++j, OracleTypes.INTEGER);
cstmt.setString(++j, userId);
cstmt.setString(++j, periodType);
cstmt.setString(++j, periodName);
cstmt.registerOutParameter(j, OracleTypes.INTEGER);
cstmt.setString(++j, process);
cstmt.setInt(++j, periodValue);
cstmt.registerOutParameter(++j,OracleTypes.CURSOR);
cstmt.registerOutParameter(++j,OracleTypes.CURSOR);
cstmt.registerOutParameter(++j,OracleTypes.CURSOR);
cstmt.registerOutParameter(++j,OracleTypes.CURSOR);
cstmt.registerOutParameter(++j,OracleTypes.CURSOR);
cstmt.registerOutParameter(++j,Types.VARCHAR);
cstmt.registerOutParameter(++j,Types.VARCHAR);
cstmt.registerOutParameter(++j,Types.VARCHAR);
cstmt.registerOutParameter(++j,Types.VARCHAR);
cstmt.registerOutParameter(++j,Types.INTEGER);
cstmt.registerOutParameter(++j,Types.VARCHAR);
cstmt.execute();
rs3 = (ResultSet)cstmt.getObject(11);
int indx = 0;
while(rs3.next()){
form.setStartWeek(rs3.getString(1));
weekDD.add(form);
System.out.println(form.getStartWeek());//am getting complete list of results
}
System.out.println(form.getStartWeek());//here am getting only one value
}
catch(Exception e){
e.printStackTrace();
}
return weekDD;
}