edu.hm.cs.goetz1.seminar.db.UserRowMapper.java Source code

Java tutorial

Introduction

Here is the source code for edu.hm.cs.goetz1.seminar.db.UserRowMapper.java

Source

/* 
 * Copyright 2014 Maximilian Goetz.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package edu.hm.cs.goetz1.seminar.db;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

import org.springframework.jdbc.core.RowMapper;

import edu.hm.cs.goetz1.seminar.model.User;

class UserRowMapper implements RowMapper<User> {

    @Override
    public User mapRow(ResultSet rs, int rowNum) throws SQLException {
        String email = rs.getString(1);
        String firstName = rs.getString(2);
        String lastName = rs.getString(3);
        String password = rs.getString(4);
        Date birthDate = rs.getDate(5);

        return new User(email, firstName, lastName, password, birthDate);
    }
}