Package java.sql

Examples of java.sql.ResultSet.first()


    }

    @Test
    public void valid_execute_nodata() throws SQLException {
        ResultSet rs = createNiceMock(ResultSet.class);
        expect(rs.first()).andReturn(false);
        replay(rs);

        Statement check = createNiceMock(Statement.class);
        expect(check.executeQuery(CHECK_QUERY)).andReturn(rs);
        replay(check);
View Full Code Here


    }

    @Test
    public void failed_close() throws SQLException {
        ResultSet rs = createNiceMock(ResultSet.class);
        expect(rs.first()).andReturn(true);
        replay(rs);

        Statement check = createNiceMock(Statement.class);
        expect(check.executeQuery(CHECK_QUERY)).andReturn(rs);
        replay(check);
View Full Code Here

                        "user=root&password=");

            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * FROM dn where dn_string = '" +
                    dn.trim() + "'");
            if (rs.first()) {
                CredUser user = new CredUser();
                user.setScreenname(dn.trim());
                user.setPassword("");
                user.setSubSystem("osg");
                return user;
View Full Code Here

        // find the default network offering created for external devices during upgrade from 2.2.14
        try {
            pstmt = conn.prepareStatement("select id from `cloud`.`network_offerings` where unique_name='Isolated with external providers' ");
            rs = pstmt.executeQuery();
            if (rs.first()) {
                    networkOfferingId = rs.getLong(1);
            } else {
                    throw new CloudRuntimeException("Cannot upgrade as there is no 'Isolated with external providers' network offering crearted .");
            }
        } catch  (SQLException e) {
View Full Code Here

            try {
        // find the F5 device id  in the zone
                pstmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalLoadBalancer' AND removed IS NULL");
                pstmt.setLong(1, zoneId);
                rs = pstmt.executeQuery();
                if (rs.first()) {
                   f5HostId  = rs.getLong(1);
                } else {
                    throw new CloudRuntimeException("Cannot upgrade as there is no F5 load balancer device found in data center " + zoneId);
                }
                pstmt = conn.prepareStatement("SELECT id FROM external_load_balancer_devices WHERE  host_id=?");
View Full Code Here

                    throw new CloudRuntimeException("Cannot upgrade as there is no F5 load balancer device found in data center " + zoneId);
                }
                pstmt = conn.prepareStatement("SELECT id FROM external_load_balancer_devices WHERE  host_id=?");
                pstmt.setLong(1, f5HostId);
                rs = pstmt.executeQuery();
                if (rs.first()) {
                        f5DeviceId = rs.getLong(1);
                } else {
                    throw new CloudRuntimeException("Cannot upgrade as there is no F5 load balancer device with host ID " + f5HostId + " found in external_load_balancer_device");
                }
View Full Code Here

            // find the SRX device id  in the zone
                pstmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalFirewall' AND removed IS NULL");
                pstmt.setLong(1, zoneId);
                rs = pstmt.executeQuery();
                if (rs.first()) {
                        srxHostId = rs.getLong(1);
                } else {
                    throw new CloudRuntimeException("Cannot upgrade as there is no SRX firewall device found in data center " + zoneId);
                }
                pstmt = conn.prepareStatement("SELECT id FROM external_firewall_devices WHERE  host_id=?");
View Full Code Here

                    throw new CloudRuntimeException("Cannot upgrade as there is no SRX firewall device found in data center " + zoneId);
                }
                pstmt = conn.prepareStatement("SELECT id FROM external_firewall_devices WHERE  host_id=?");
                pstmt.setLong(1, srxHostId);
                rs = pstmt.executeQuery();
                if (rs.first()) {
                        srxDevivceId = rs.getLong(1);
                } else {
                    throw new CloudRuntimeException("Cannot upgrade as there is no SRX firewall device found with host ID " + srxHostId + " found in external_firewall_devices");
                }
View Full Code Here

                    tag = res_tags_RS.getString(1);
                    res_tag_users_STMT.setString(1, tag);
                    res_tag_users_STMT.setNString(2,main_res_id);
                    res_tag_users_RS = res_tag_users_STMT.executeQuery();
                    temp += "t = \"" + tag + "\" OR ";
                    res_tag_users_RS.first();
                    main_res.setTF(tag, res_tag_users_RS.getInt(1));
                    f2r1 += res_tag_users_RS.getInt(1)*res_tag_users_RS.getInt(1);
                }
                main_res.setF(f2r1);
                res_users_STMT.setNString(1, main_res_id);
View Full Code Here

        Connection c = DataConnection.getDataConnection(DataConnection.POSTCORE);
        try{
        Statement randomResStmt = c.createStatement();
        if(c!=null){
            ResultSet tagRS = randomResStmt.executeQuery("SELECT content_id FROM tas ORDER BY RAND() LIMIT 1");
            tagRS.first();
            CollaborativeFiltering cf = new CollaborativeFiltering(tagRS.getInt(1));
            //cf.doRTFiltering(c, 688049);
        }}catch(SQLException ex){}

    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.