Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* it's here the source of the ArrayList functions when i'm to build the query in mysql */
- public ArrayList listar(ConexionSicodet conn, String valor) throws SQLException{
- ArrayList arreglo= new ArrayList();
- stm = conn.stm;
- res = stm.executeQuery("select iddelito as id, upper(descripcion) as descripcion, estatus as estatus from delito where descripcion like '%"+valor.toUpperCase()+"%' ");
- ResultSetMetaData rsmd = res.getMetaData();
- int columnas = rsmd.getColumnCount();
- while(res.next()){
- HashMap fila = new HashMap();
- arreglo.add(fila);
- for(int i = 0; i < columnas; i++){
- fila.put(rsmd.getColumnName(i+1), res.getObject(i+1));
- //System.out.println(arreglo.get(i));
- //System.out.println("Registro: "+rsmd.getColumnName(i+1)+"\nobjeto: "+res.getObject(i+1));
- }
- }
- return arreglo;
- }
- public static void main(String []args){
- ConexionSicodet conn = new ConexionSicodet();
- ModeloDelito md = new ModeloDelito();
- ArrayList arreglo = md.listar(conn, "valor");
- int tamano = arreglo.size();
- if(tamano>0){
- for(int i = 0; i<tamano; i++){
- System.out.println(arreglo.get(i));
- }
- }else{
- System.out.println("arreglo vacio!");
- }
- }
- /* the problems is thats i can not to select the field of the object of the ArrayList */
Add Comment
Please, Sign In to add comment