List of usage examples for java.sql ResultSet getBoolean
boolean getBoolean(String columnLabel) throws SQLException;
ResultSet
object as a boolean
in the Java programming language. From source file:com.company.dao.impl.StudentDAOImpl.java
private Student mapData(ResultSet rs) throws SQLException { Student student = new Student(); student.setId(rs.getInt("id")); student.setFirstName(rs.getString("first_name")); student.setLastName(rs.getString("last_name")); student.setEmail(rs.getString("email")); student.setContactNo(rs.getString("contact_no")); student.setGender(rs.getString("gender")); student.setDob(rs.getDate("dob")); student.setStatus(rs.getBoolean("status")); student.setAddedDate(rs.getDate("added_date")); student.setModifedDate(rs.getDate("modified_date")); student.setDeletedDate(rs.getDate("delete_date")); student.setDeleteIP(rs.getString("delete_ip")); return student; }
From source file:com.leapfrog.inventorymanagementsystem.dao.impl.SupplierDAOImpl.java
@Override public Supplier getById(int id) throws SQLException, ClassNotFoundException { String sql = "SELECT * FROM tbl_supplier WHERE supplier_id =?"; return jdbcTemplate.queryForObject(sql, new Object[] { id }, new RowMapper<Supplier>() { @Override/*from ww w . j a va 2 s . com*/ public Supplier mapRow(ResultSet rs, int i) throws SQLException { Supplier s = new Supplier(); s.setId(rs.getInt("supplier_id")); s.setSupplierName(rs.getString("supplier_name")); s.setAddress(rs.getString("address")); s.setContact(rs.getString("contact")); s.setEmail(rs.getString("email")); s.setAddedDate(rs.getDate("added_date")); s.setStatus(rs.getBoolean("status")); return s; } }); }
From source file:com.leapfrog.inventorymanagementsystem.dao.impl.SupplierDAOImpl.java
@Override public List<Supplier> getALL() throws SQLException, ClassNotFoundException { String sql = "SELECT * FROM tbl_supplier"; return jdbcTemplate.query(sql, new RowMapper<Supplier>() { @Override/*from ww w.jav a 2 s.c om*/ public Supplier mapRow(ResultSet rs, int i) throws SQLException { Supplier s = new Supplier(); s.setId(rs.getInt("supplier_id")); s.setSupplierName(rs.getString("supplier_name")); s.setAddress(rs.getString("address")); s.setContact(rs.getString("contact")); s.setEmail(rs.getString("email")); s.setAddedDate(rs.getDate("added_date")); s.setStatus(rs.getBoolean("status")); return s; } }); }
From source file:com.rockagen.gnext.service.spring.security.extension.BasicJdbcDaoImpl.java
/** * Executes the SQL <tt>usersByUsernameQuery</tt> and returns a list of * UserDetails objects. There should normally only be one matching user. */// ww w . j a va 2 s . c o m protected List<BasicSecurityUser> loadUsersByUsername(String username) { return getJdbcTemplate().query(usersByUsernameQuery, new String[] { username }, new RowMapper<BasicSecurityUser>() { public BasicSecurityUser mapRow(ResultSet rs, int rowNum) throws SQLException { String username = rs.getString(1); String password = rs.getString(2); boolean enabled = rs.getBoolean(3); String mername = rs.getString(4); String email = rs.getString(5); String latestIp = rs.getString(6); return new BasicSecurityUser(username, password, enabled, true, true, true, AuthorityUtils.NO_AUTHORITIES, mername, email, latestIp); } }); }
From source file:com.flexive.core.storage.MySQL.MySQLSequencerStorage.java
/** * {@inheritDoc}// ww w .j ava 2s. c om */ @Override public long fetchId(String name, boolean allowRollover) throws FxCreateException { Connection con = null; PreparedStatement ps = null; try { // Obtain a database connection con = Database.getDbConnection(); // Prepare the new id ps = con.prepareStatement(SQL_NEXT); ps.setString(1, name); ps.executeUpdate(); if (ps.getUpdateCount() == 0) throw new FxCreateException(LOG, "ex.sequencer.typeUnknown", name); ps.close(); // Get the new id ps = con.prepareStatement(SQL_GETID); ResultSet rs = ps.executeQuery(); long newId; if (rs == null || !rs.next()) throw new FxCreateException(LOG, "ex.sequencer.fetch.failed", name); newId = rs.getLong(1); if (rs.wasNull()) throw new FxCreateException(LOG, "ex.sequencer.fetch.failed", name); if (newId >= MAX_ID) { if (!name.startsWith("SYS_")) { //get allowRollover setting ps.close(); ps = con.prepareStatement(SQL_GET_ROLLOVER); ps.setString(1, name); ResultSet rso = ps.executeQuery(); if (rso == null || !rso.next()) throw new FxCreateException(LOG, "ex.sequencer.fetch.failed", name); allowRollover = rso.getBoolean(1); } if (!allowRollover) throw new FxCreateException("ex.sequencer.exhausted", name); ps.close(); ps = con.prepareStatement(SQL_RESET); ps.setString(1, name); ps.executeUpdate(); if (ps.getUpdateCount() == 0) throw new FxCreateException(LOG, "ex.sequencer.typeUnknown", name); newId = 0; } // Return new id return newId; } catch (SQLException exc) { throw new FxCreateException(LOG, exc, "ex.sequencer.fetch.failedMsg", name, exc.getMessage()); } finally { Database.closeObjects(MySQLSequencerStorage.class, con, ps); } }
From source file:org.onesun.atomator.dao.SubscriptionDAOImpl.java
private SubscriptionEntry toSubscriptionEntry(ResultSet resultSet) throws SQLException { String identity = (resultSet.getString("identity")); String user = (resultSet.getString("user_id")); String description = (resultSet.getString("description")); String channelType = (resultSet.getString("channel_type")); String action = (resultSet.getString("action")); String feedURL = (resultSet.getString("feedURL")); boolean enabled = (resultSet.getBoolean("enabled")); boolean fullText = (resultSet.getBoolean("full_text")); String feedGroupId = (resultSet.getString("feed_group_id")); // TODO: ChannelType and description into DB SubscriptionEntry entry = new SubscriptionEntry(action, description, channelType, identity, user, feedURL, fullText, feedGroupId);/* ww w .j a v a 2s .co m*/ entry.setEnabled(enabled); return entry; }
From source file:com.havoc.hotel.admin.dao.impl.UserDAOImpl.java
private User mapData(ResultSet rs) throws SQLException { User u = new User(); u.setUserId(rs.getInt("user_id")); u.setFirstName(rs.getString("first_name")); u.setLastName(rs.getString("last_name")); u.setEmail(rs.getString("email")); u.setUsername(rs.getString("username")); u.setPassword(rs.getString("password")); u.setRoleId(rs.getInt("role_id")); u.setAddedDate(rs.getDate("added_date")); u.setStatus(rs.getBoolean("status")); return u;// ww w.j a v a 2 s .com }
From source file:dk.dma.msinm.legacy.msi.service.LegacyMsiImportService.java
private Boolean getBoolean(ResultSet rs, String key) throws SQLException { boolean val = rs.getBoolean(key); return rs.wasNull() ? null : val; }
From source file:net.sf.l2j.gameserver.model.entity.Couple.java
public Couple(int coupleId) { _Id = coupleId;/*from ww w .ja v a 2s .c o m*/ java.sql.Connection con = null; try { PreparedStatement statement; ResultSet rs; con = L2DatabaseFactory.getInstance().getConnection(); statement = con.prepareStatement("Select * from couples where id = ?"); statement.setInt(1, _Id); rs = statement.executeQuery(); while (rs.next()) { _player1Id = rs.getInt("player1Id"); _player2Id = rs.getInt("player2Id"); _maried = rs.getBoolean("maried"); _affiancedDate = Calendar.getInstance(); _affiancedDate.setTimeInMillis(rs.getLong("affiancedDate")); _weddingDate = Calendar.getInstance(); _weddingDate.setTimeInMillis(rs.getLong("weddingDate")); } statement.close(); this._maried = true; } catch (Exception e) { _log.error("Exception: Couple.load(): " + e.getMessage(), e); } finally { try { con.close(); } catch (Exception e) { } } }