Example usage for java.sql ResultSet next

List of usage examples for java.sql ResultSet next

Introduction

In this page you can find the example usage for java.sql ResultSet next.

Prototype

boolean next() throws SQLException;

Source Link

Document

Moves the cursor forward one row from its current position.

Usage

From source file:com.l2jfree.gameserver.instancemanager.RaidPointsManager.java

public static void init() {
    _list.clear();/*from   www  .  j av  a2s .c om*/

    Connection con = null;
    try {
        con = L2DatabaseFactory.getInstance().getConnection();
        PreparedStatement statement = con.prepareStatement("SELECT * FROM character_raid_points");
        ResultSet rset = statement.executeQuery();

        while (rset.next())
            getList(rset.getInt("charId")).put(rset.getInt("boss_id"), rset.getInt("points"));

        rset.close();
        statement.close();
    } catch (Exception e) {
        _log.warn("", e);
    } finally {
        L2DatabaseFactory.close(con);
    }
}

From source file:com.data2semantics.yasgui.server.db.ConnectionFactory.java

private static ArrayList<Integer> getDeltas(Connection connect) throws SQLException {
    ArrayList<Integer> deltaIds = new ArrayList<Integer>();
    String sql = "SELECT Id FROM Deltas WHERE 1 ORDER BY Id ASC";
    Statement statement = connect.createStatement();
    ResultSet result = statement.executeQuery(sql);
    while (result.next()) {
        deltaIds.add(result.getInt("Id"));
    }//from   w w  w .j av a 2s .  c o  m
    return deltaIds;
}

From source file:org.red5.server.plugin.admin.dao.UserDAO.java

public static UserDetails getUser(String username) {
    UserDetails details = null;//from   ww  w.  j a  v  a 2s .  c o  m
    Connection conn = null;
    PreparedStatement stmt = null;
    try {
        // JDBC stuff
        DataSource ds = UserDatabase.getDataSource();

        conn = ds.getConnection();
        //make a statement
        stmt = conn.prepareStatement("SELECT * FROM APPUSER WHERE username = ?");
        stmt.setString(1, username);
        ResultSet rs = stmt.executeQuery();
        if (rs.next()) {
            log.debug("User found");
            details = new UserDetails();
            details.setEnabled("enabled".equals(rs.getString("enabled")));
            details.setPassword(rs.getString("password"));
            details.setUserid(rs.getInt("userid"));
            details.setUsername(rs.getString("username"));
            //
            rs.close();
            //get role            
            stmt = conn.prepareStatement("SELECT authority FROM APPROLE WHERE username = ?");
            stmt.setString(1, username);
            rs = stmt.executeQuery();
            if (rs.next()) {
                Collection<? extends GrantedAuthority> authorities;
                //                  authorities.addAll((Collection<?>) new GrantedAuthorityImpl(rs.getString("authority")));
                //                  details.setAuthorities(authorities);
                //
                //if (daoAuthenticationProvider != null) {
                //User usr = new User(username, details.getPassword(), true, true, true, true, authorities);
                //daoAuthenticationProvider.getUserCache().putUserInCache(usr);               
                //}
            }
        }
        rs.close();
    } catch (Exception e) {
        log.error("Error connecting to db", e);
    } finally {
        if (stmt != null) {
            try {
                stmt.close();
            } catch (SQLException e) {
            }
        }
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
            }
        }
    }
    return details;
}

From source file:de.griffel.confluence.plugins.plantuml.DatasourceHelper.java

private static List<String> getCatalogs(DatabaseMetaData dbmd) throws SQLException {
    final List<String> catalogNames = new LinkedList<String>();
    final ResultSet rs = dbmd.getCatalogs();
    while (rs.next()) {
        catalogNames.add(rs.getString(1));
    }/*ww w  .jav  a 2s. c  o  m*/
    rs.close();
    return catalogNames;
}

From source file:com.ineunet.knife.persist.PersistUtils.java

public static boolean existsTable(final String tableName, JdbcTemplate jdbcTemplate) {
    return jdbcTemplate.query("show tables", new ResultSetExtractor<Boolean>() {
        @Override/*  w  w  w  . j a va 2 s  . c o m*/
        public Boolean extractData(ResultSet rs) throws SQLException, DataAccessException {
            while (rs.next()) {
                String tableNameOther = rs.getString(1);
                if (tableName.equalsIgnoreCase(tableNameOther))
                    return true;
            }
            return false;
        }
    });
}

From source file:com.bluepandora.therap.donatelife.service.CheckService.java

public static boolean isNameAlreadyAdded(String firstName, String lastName, DatabaseService dbService) {

    String query = GetQuery.getPersonNameIdQuery(firstName, lastName);
    ResultSet result = dbService.getResultSet(query);
    boolean nameTaken = false;
    try {/* ww  w  . ja v  a  2s  . c  o m*/
        while (result.next()) {
            nameTaken = true;
        }
    } catch (SQLException error) {
        Logger.getLogger(CheckService.class.getName()).log(Level.SEVERE, null, error);
    }

    return nameTaken;
}

From source file:de.griffel.confluence.plugins.plantuml.DatasourceHelper.java

public static List<String> getTableTypes(DatabaseMetaData dbmd) throws SQLException {
    final List<String> tableTypes = new LinkedList<String>();
    final ResultSet rs = dbmd.getTableTypes();
    while (rs.next()) {
        tableTypes.add(rs.getString(1));
    }/*from w w  w . j a  va  2 s  . c o  m*/
    rs.close();
    return tableTypes;
}

From source file:com.bluepandora.therap.donatelife.service.CheckService.java

public static boolean isValidUser(String mobileNumber, String hashKey, DatabaseService dbService) {

    String query = GetQuery.getValidUserQuery(mobileNumber, hashKey);
    // Debug.debugLog("VALID USER QUERY: ", query);
    ResultSet result = dbService.getResultSet(query);
    boolean USER_VALID = false;
    try {/*from  w w w  .  j a  va 2s  . c om*/
        while (result.next()) {
            USER_VALID = true;
        }
    } catch (SQLException error) {
        Logger.getLogger(CheckService.class.getName()).log(Level.SEVERE, null, error);
    }
    return USER_VALID;
}

From source file:com.bluepandora.therap.donatelife.service.CheckService.java

public static boolean isDuplicateBloodGroup(String mobileNumber, String groupId, DatabaseService dbService) {

    String query = GetQuery.getDuplicateBloodGroupQuery(mobileNumber, groupId);
    // Debug.debugLog("DUPLICATE BLOOD GROUP QUERY: ", query);
    ResultSet result = dbService.getResultSet(query);
    boolean VALID_GROUP = true;
    try {//from  ww  w .j a v a  2s .co  m
        while (result.next()) {
            VALID_GROUP = false;
        }
    } catch (SQLException err) {
        Logger.getLogger(CheckService.class.getName()).log(Level.SEVERE, null, err);
    }
    return VALID_GROUP;
}

From source file:database.DBAccountManager.java

public static String getEntry(String table, String id, String type) throws SQLException {
    ResultSet rs = Connector
            .selectQuery("SELECT " + type + " FROM " + Sql.DB + "." + table + " WHERE id = '" + id + "';");
    rs.next();
    return rs.getString(type);
}