Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
public class Person
{
private string firstName = null;
private string lastName = null;
public Person()
{
}
public String getFirstName()
{
return this.firstName;
}
public void setFirstName(string aValue)
{
this.firstName = aValue;
}
public String getLastName()
{
return this.lastName;
}
public void setLastName(string aValue)
{
this.lastName = aValue;
}
}
import java.sql.Connection;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import [your Person class];
public abstract class PersonFactory
{
public static ArrayList getPersons(String aLastName)
throws SQLException
{
ArrayList result = null;
Connection con = null;
CallableStatement stmt = null;
ResultSet rs = null;
try
{
con = [get a connection];
stmt = con.prepareCall("{call proc_name[(?)]}");
stmt.setString(1, aLastName);
rs = stmt.executeQuery();
result = materialize(rs);
}
finally
{
try
{
rs.close();
}
catch (SQLException closeException)
{
}
try
{
stmt.close();
}
catch (SQLException closeException)
{
}
try
{
con.close();
}
catch (SQLException closeException)
{
}
}
return result;
}
/**
* Materializes all rows in ResultSet.
*/
private static Collection materialize(ResultSet rs)
throws SQLException
{
Person person = null;
// ensure result is not null;
ArrayList result = new ArrayList();
while (rs.next())
{
person = materializeSingle(rs);
result.add(person);
}
return result;
}
/**
* Materializes each row in ResultSet, creating
* an object from the row at the current cursor position.
*/
private static Person materializeSingle(ResultSet rs)
throws SQLException
{
Person person = new Person();
person.setFirstName(rs.getString("FName));
person.setLastName(rs.getString("LName));
return person;
}
}