List of usage examples for org.springframework.jdbc.support.rowset SqlRowSet isLast
boolean isLast() throws InvalidResultSetAccessException;
From source file:test.Test_User.java
public void xx() { String name = "GoW"; String sql = "select password, id from fc_user " + " where name_login = " + DaoTemplate.quote(name); SqlRowSet rowSet = userDao.getJdbcTemplate().queryForRowSet(sql); System.out.println((rowSet.isLast())); if (rowSet.next()) { System.out.println((rowSet.isLast())); System.out.println(sql + "\n"); String result = rowSet.getString("id"); System.err.println(result); }//from w w w. ja va2s . c om }
From source file:gov.nih.nci.ncicb.tcga.dcc.QCLiveTestDataGeneratorSlowTest.java
/** * Tests the {@link QCLiveTestDataGenerator#generateTestData(String)} method with a valid archive name * and check assertions to verify that CNTL test data was loaded. *//*from www.j a v a2 s.c o m*/ @Test public void testLoadCNTLTestDataForNonCNTLArchive() throws IOException, SQLException, ParseException { // Retrieve the QCLiveTestDataGenerator from the Spring context and invoke it using a valid archive name ((QCLiveTestDataGenerator) testAppCtx.getBean("qcLiveTestDataGenerator")) .generateTestData("nationwidechildrens.org_BRCA.bio.Level_1.85.21.0"); final JdbcTemplate diseaseLocalJdbcTemplate = (JdbcTemplate) testAppCtx.getBean("diseaseLocalJdbcTemplate"); final SqlRowSet rowSet = diseaseLocalJdbcTemplate.queryForRowSet("select * from data_level"); assertNotNull(rowSet); assertTrue(rowSet.first()); assertEquals(1, rowSet.getInt("level_number")); assertEquals("cAsESeNsItIvE", rowSet.getString("level_definition")); assertTrue(rowSet.isLast()); }
From source file:net.freechoice.dao.impl.DaoUser.java
@Warning(values = { "injection" }) @Deprecated/*from w w w . j a v a 2 s . c o m*/ @Override public AvgUser getRoleByEmail(final String email) { AvgUser role = null; SqlRowSet rowSet = getJdbcTemplate().queryForRowSet("select U.id, U.password, U.name_login, M.value " + " from FC_User as U left outer join FC_User_Meta as M " + " on U.id = M.id_user_ " + " where U.is_valid = true and email = " + quote(email) + " and M.key = " + SuperUser.TIME_EXPIRE); if (rowSet.next()) { if (rowSet.isLast()) { /** * only super user have expire time */ String timeExpire = rowSet.getString(4); if (timeExpire == null || (timeExpire != null && DateUtil.hasExpired(timeExpire))) { role = new AvgUser(); } else { role = new SuperUser(); } role.id = rowSet.getInt(1); role.hashedPswWithSalt = rowSet.getString(2); role.name_login = rowSet.getString(3); role.email = email; } else { throw new RuntimeException("multiple user found, should be one only"); } } return role; }
From source file:net.freechoice.dao.impl.DaoUser.java
@Deprecated @Override/* w w w .ja v a 2 s . c o m*/ public Result getPasswordOfUser(String nameOrEmail) { SqlRowSet rowSet; if (nameOrEmail.contains("@")) { rowSet = getJdbcTemplate().queryForRowSet("select id, password from fc_user " + "where is_valid = true and email = " + quote(nameOrEmail)); } else { rowSet = getJdbcTemplate().queryForRowSet("select id, password from fc_user " + "where is_valid = true and name_login = " + quote(nameOrEmail)); } if (rowSet.next()) { if (rowSet.isLast()) { Result result = new Result(); result.id = rowSet.getInt(1); result.password = rowSet.getString(2); return result; } else { throw new RuntimeException("multiple user found, should be one only"); } } else { return null; } }
From source file:net.freechoice.dao.impl.DaoUser.java
@Deprecated @Override// ww w.j a va 2s.c o m public AvgUser getRoleByLoginName(final String loginName) { AvgUser role = null; SqlRowSet rowSet = getJdbcTemplate().queryForRowSet("select U.id, U.password, U.email, M.value " + " from FC_User as U left outer join FC_User_Meta as M " + " on U.id = M.id_user_ " + " where U.is_valid = true and name_login = " + quote(loginName) + " and M.key = " + quote(SuperUser.TIME_EXPIRE)); //System.err.println("SQL:" + // "select U.id, U.password, U.email, M.value " // + " from FC_User as U left outer join FC_User_Meta as M " // +" on U.id = M.id_user_ " // +" where U.is_valid = true and name_login = " + quote(loginName) // +" and M.key = " + quote(SuperUser.TIME_EXPIRE) // ); if (rowSet.next()) { if (rowSet.isLast()) { /** * only super user have expire time */ String timeExpire = rowSet.getString(4); if (timeExpire == null || (timeExpire != null && DateUtil.hasExpired(timeExpire))) { role = new AvgUser(); } else { role = new SuperUser(); } role.id = rowSet.getInt(1); role.hashedPswWithSalt = rowSet.getString(2); role.email = rowSet.getString(3); role.name_login = loginName; } else { throw new RuntimeException("multiple user found, should be one only"); } } return role; }