/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package database_teste; import com.mysql.jdbc.Connection; import com.mysql.jdbc.PreparedStatement; import com.mysql.jdbc.ResultSet; import java.sql.SQLException; import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Andre */ public class Consulta { public Vector selectAll(){ Vector vetor = new Vector(); Connection conn = null; conn = (Connection) Conexao.conexao(); try { String sql = "select * from locadora"; PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql); ps.execute(); ResultSet rs = (ResultSet) ps.getResultSet(); while(rs.next()){ Integer cod = rs.getInt(1); vetor.add(cod); String nome = rs.getString(2); vetor.add(nome); String genero = rs.getString(3); vetor.add(genero); } } catch (Exception e) { e.printStackTrace(); } finally { try { conn.close(); } catch (SQLException ex) { Logger.getLogger(Consulta.class.getName()).log(Level.SEVERE, null, ex); } } return vetor; } }