List of usage examples for java.sql ResultSet getInt
int getInt(String columnLabel) throws SQLException;
ResultSet
object as an int
in the Java programming language. From source file:biz.wolschon.finance.jgnucash.mysql.impl.SplitRowMapper.java
/** * @param aResultSet the result-set whos current result to map * @param aRowNumber the current row-number in the result-set * @return the result mapped to a bean//from w w w .ja v a 2s . c om * @throws SQLException on problems with the database * @see org.springframework.jdbc.core.simple.ParameterizedRowMapper#mapRow(java.sql.ResultSet, int) */ @Override public GnucashDBSplit mapRow(final ResultSet aResultSet, final int aRowNumber) throws SQLException { int vnum = aResultSet.getInt("value_num"); int vdenum = aResultSet.getInt("value_denom"); int qnum = aResultSet.getInt("quantity_num"); int qdenum = aResultSet.getInt("quantity_denom"); FixedPointNumber quantity = new FixedPointNumber(qnum + "/" + qdenum); FixedPointNumber value = new FixedPointNumber(vnum + "/" + vdenum); GnucashDBSplit retval = new GnucashDBSplit(myGnucashFile, aResultSet.getString("guid"), aResultSet.getString(ROWTRANSACTIONGUID), aResultSet.getString("lot_guid"), aResultSet.getString("account_guid"), aResultSet.getString("memo"), aResultSet.getString("action"), value, quantity); return retval; }
From source file:net.chrisrichardson.bankingExample.domain.jdbc.JdbcAccountDao.java
public Account findAccount(String accountId) { logger.debug("finding account"); return (Account) jdbcTemplate.queryForObject("SELECT * FROM BANK_ACCOUNT WHERE accountId = ?", new Object[] { accountId }, new RowMapper() { public Object mapRow(ResultSet rs, int rowNum) throws SQLException { return new Account(rs.getInt("ACCOUNT_ID"), rs.getString("accountId"), rs.getDouble("BALANCE"), rs.getInt("overdraftPolicy"), new Date(rs.getTimestamp("dateOpened").getTime()), rs.getDouble("requiredYearsOpen"), rs.getDouble("limit")); }/*from w w w.jav a2 s .c om*/ }); }
From source file:com.havoc.hotel.admin.dao.impl.CheckoutDAOImpl.java
private Checkout mapData(ResultSet rs) throws SQLException { Checkout checkout = new Checkout(); checkout.setCheckoutId(rs.getInt("checkout_id")); Checkin c = new Checkin(); c.setCheckinId(rs.getInt("checkin_id")); Booking b = new Booking(); b.setFirstName(rs.getString("first_name")); b.setLastName(rs.getString("last_name")); b.setCheckinDate(rs.getDate("checkin_date")); b.setCheckoutDate(rs.getDate("checkout_date")); b.setTotalDays(rs.getInt("total_days")); b.setTotalNights(rs.getInt("total_nights")); b.setTotalPrice(rs.getInt("total_price")); Room r = new Room(); r.setRoomNumber(rs.getInt("room_number")); r.setRoomPrice(rs.getInt("room_price")); c.setBooking(b);/* ww w .java 2 s . co m*/ checkout.setCheckin(c); return checkout; }
From source file:repository.ItemsDAO.java
public List<Items> getItemsList() { return template.query("SELECT * FROM items", new RowMapper<Items>() { public Items mapRow(ResultSet rs, int row) throws SQLException { Items a = new Items(); a.setItemcode(rs.getInt("itemcode")); a.setDescription(rs.getString("description")); a.setCost(rs.getInt("cost")); return a; }/*w ww .ja v a 2 s .c o m*/ }); }
From source file:com.javaetmoi.elasticsearch.musicbrainz.batch.mapper.AlbumRowMapper.java
@Override public Album mapRow(ResultSet rs, int rowNum) throws SQLException { Album album = new Album(); album.setId(rs.getInt("albumId")); album.setGid(rs.getString("albumGid")); album.setName(rs.getString("albumName")); album.setTypeId(rs.getInt("albumPrimaryTypeId")); album.setTypeName(rs.getString("albumPrimaryTypeName")); album.setYear(rs.getInt("albumYear")); album.getRating().setScore(rs.getInt("albumRatingScore")); album.getRating().setCount(rs.getInt("albumRatingCount")); Artist artist = album.getArtist();/*from w w w.ja va 2 s . c o m*/ artist.setGid(rs.getString("artistGid")); artist.setName(rs.getString("artistName")); artist.setBeginDateYear(rs.getString("artistBeginDateYear")); if (rs.getObject("artistTypeId") != null) { artist.setTypeId(rs.getInt("artistTypeId")); } if (rs.getObject("artistTypeName") != null) { artist.setTypeName(rs.getString("artistTypeName")); } if (rs.getObject("artistGenderId") != null) { artist.setGender(Gender.valueOf(rs.getInt("artistGenderId"))); } artist.setArea(rs.getString("artistCountryName")); artist.getRating().setScore(rs.getInt("artistRatingScore")); artist.getRating().setCount(rs.getInt("artistRatingCount")); return album; }
From source file:com.dai.jdbc.JogadorEquipaAdversariaExtractor.java
public JogadorEquipaAdversaria extractData(ResultSet resultSet) throws SQLException, DataAccessException { JogadorEquipaAdversaria jea = new JogadorEquipaAdversaria(); jea.setIdJogador(resultSet.getInt("idJogadorEquipaAdversaria")); jea.setNome(resultSet.getString("nomeJogador")); jea.setPosicao(resultSet.getString("posicaoJogador")); jea.setIdEquipaAdversaria(resultSet.getInt("equipaAdversaria_idEquipaAdversaria")); return jea;//from www. j ava2 s .co m }
From source file:com.leapfrog.academyspring.dao.impl.CourseDAOImpl.java
private Course mapData(ResultSet rs) throws SQLException { Course cor = new Course(); cor.setId(rs.getInt("id")); cor.setName(rs.getString("name")); cor.setDescription(rs.getString("description")); cor.setCourseDuration(rs.getInt("course_duration")); cor.setDurationType(rs.getString("duration_type")); cor.setFees(rs.getDouble("fees")); cor.setAddedDate(rs.getDate("added_date")); cor.setModifiedDate(rs.getDate("modified_date")); cor.setDeleteFlag(rs.getBoolean("delete_flag")); cor.setDeleteDate(rs.getDate("delete_date")); cor.setStatus(rs.getBoolean("status")); return cor;/*from www. ja v a 2s. c o m*/ }
From source file:com.senior.g40.service.AccidentService.java
private void setAccident(ResultSet rs, Accident ac) throws SQLException { ac.setUserId(rs.getInt("userId")); ac.setDate(rs.getDate("date")); ac.setTime(rs.getString("time")); ac.setLatitude(rs.getFloat("latitude")); ac.setLongtitude(rs.getFloat("longtitude")); ac.setForceDetect(rs.getFloat("forceDetect")); ac.setSpeedDetect(rs.getFloat("speedDetect")); ac.setAccCode(rs.getString("accCode").charAt(0)); }
From source file:dk.netarkivet.common.utils.DBUtils.java
/** Execute an SQL statement and return the single integer * in the result set./* www . j ava 2s. c o m*/ * * @param s A prepared statement * @return The integer result, or null if the result value was null. * @throws IOFailure if the statement didn't result in exactly one integer. */ public static Integer selectIntValue(PreparedStatement s) { ArgumentNotValid.checkNotNull(s, "PreparedStatement s"); try { ResultSet res = s.executeQuery(); if (!res.next()) { throw new IOFailure("No results from " + s); } Integer resultInt = res.getInt(1); if (res.wasNull()) { resultInt = null; } if (res.next()) { throw new IOFailure("Too many results from " + s); } return resultInt; } catch (SQLException e) { throw new IOFailure( "SQL error executing statement " + s + "\n" + ExceptionUtils.getSQLExceptionCause(e), e); } }
From source file:BBDDMapper.Int_StringMapper.java
@Override public Object mapRow(ResultSet rs, int i) throws SQLException { Int_String intString = new Int_String(); intString.setTexto(rs.getString(2)); intString.setValor(rs.getInt(1)); return intString; }