RetrieveSubjectsBackingBean; /** Copyright 2012 Dököll Solutions, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. * Program: RetrieveSubjectsBackingBean.java * Created from Copy: 2012.11.21.8.05.PM * New Retrieval Bean from DB2 via Xpages * */ package com.dokoll.solutions.inc.search; //... //java imports import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; //faces imports import javax.faces.context.FacesContext; import javax.servlet.http.HttpServletRequest; //Döcu imports import com.dokoll.solutions.inc.Utils.DB2Connector; import com.dokoll.solutions.inc.db2.test.SubjectsInfo; /** * @author Dököll Solutions, Inc. * @version 2012.11.21.8.05.PM * */ @ManagedBean @RequestScoped public class RetrieveSubjectsBackingBean { // Get SubjectsInfo collection @SuppressWarnings( { "null", "unchecked" }) public SubjectsInfo[] getKeywords() { // Declare SubjectsInfo Array SubjectsInfo[] keywords = null; try { //... Connection connection = DB2Connector.getConnection(); Statement stat = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); connection.setAutoCommit(true); ResultSet rs = stat.executeQuery("select * from DB2ADMIN.USER_DETAILS"); //... //declare and initialize counts int docount = 0; int rowcount = 0; if (rs.last()) { rowcount = rs.getRow(); rs.beforeFirst(); keywords = new SubjectsInfo[rowcount]; //submit results to Xpages form while (rs.next()) { //call String SubID,String UserName,String AllegationCode,String Office, String Investigator.... SubjectsInfo keyword = new SubjectsInfo(null, null, null, null, null, null, null, null, null, null,null,null); //loads DB2 results into SubjectsInfo object... keyword.setSubID(rs.getString("ID")); keyword.setUserName(rs.getString("UserName")); keyword.setAllegationCode(rs.getString("AllegationCode")); keyword.setInvestigator(rs.getString("Investigator"));// keyword.setDateOpen(rs.getString("DateOpen"));// keyword.setOffice(rs.getString("Office"));// keyword.setAge(rs.getString("Age"));// keyword.setOffice(rs.getString("Office"));// keyword.setAllegationNumber(rs.getString("AllegationNumber"));// keyword.setLicensee(rs.getString("Licensee"));// keyword.setSubject(rs.getString("Subject"));// keywords[docount] = keyword; // increment counts docount += 1; } rs.close(); connection.close(); } // return the Array return keywords; //catch accordingly } catch (Exception e) { e.printStackTrace(); } // return nothing return null; } }