Example usage for javax.resource.cci ResultSet getString

List of usage examples for javax.resource.cci ResultSet getString

Introduction

In this page you can find the example usage for javax.resource.cci ResultSet getString.

Prototype

String getString(int columnIndex) throws SQLException;

Source Link

Document

Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.

Usage

From source file:org.springframework.samples.jca.dao.PersonDaoImpl.java

/**
 * @see org.springframework.samples.jca.dao.PersonneDao#getPerson(int)
 *///from   www  .ja  v  a 2  s.  c  o  m
public Person getPerson(final int id) throws PersonException {
    CciInteractionSpec interactionSpec = new CciInteractionSpec();
    /*interactionSpec.setUser("sa");
    interactionSpec.setPassword("");*/
    interactionSpec.setSql("select * from person where person_id=?");

    List people = (List) getCciTemplate().execute(interactionSpec, new RecordCreator() {
        public Record createRecord(RecordFactory recordFactory) throws ResourceException, DataAccessException {
            IndexedRecord input = recordFactory.createIndexedRecord("input");
            input.add(new Integer(id));
            return input;
        }
    }, new RecordExtractor() {
        public Object extractData(Record record) throws ResourceException, SQLException, DataAccessException {
            List people = new ArrayList();
            ResultSet rs = (ResultSet) record;
            while (rs.next()) {
                Person person = new Person();
                person.setId(rs.getInt("person_id"));
                person.setLastName(rs.getString("person_last_name"));
                person.setFirstName(rs.getString("person_first_name"));
                people.add(person);
            }
            return people;
        }
    });

    if (people.size() == 1) {
        return (Person) people.get(0);
    } else {
        throw new PersonException("Can't the person");
    }
}