bueno mi consulta es la siguiente necesito crear una clase que me ayude a ahorrar codigo
porque tengo 2 funciones los cuales me rellena y dibujan un Jtable cn un result set pero es demaciado codigo   
Código Javascript
:
Ver original- private void dibujarcom(){ 
-         try{ 
-             sentencia = con.createStatement(); 
-             rs = sentencia.executeQuery("select count(0) as Cantidad from comunas"); 
-             int numero = 0; 
-             if(rs.next()){ 
-                 numero =rs.getInt("Cantidad"); 
-             } 
-             sentencia.close(); 
-   grillacom.setModel(new javax.swing.table.DefaultTableModel( 
-                     new Object[numero][4], 
-                     new String[]{ 
-                     "Codigo","Nombre","Region" 
-                     } 
-                     )); 
-             llenarcom(); 
-         }catch(SQLException e1){ 
-          javax.swing.JOptionPane.showMessageDialog(this, "Error en Dibujar la Grilla SQL", "ERROR", 0); 
-   
-         }catch(Exception e2){ 
-             javax.swing.JOptionPane.showMessageDialog(this, "Error al dibujar", "ERROR", 0); 
-   
-         } 
-   
-   
-     } 
-   
-   
-   
- private void llenarcom(){ 
-     String sel; 
-     int x; 
-     try{ 
-         sel="SELECT comunas.cod AS cod, comunas.nombre AS nombre, regiones.nombre AS region FROM comunas, regiones WHERE comunas.region = regiones.cod "; 
-         sentencia=con.createStatement(); 
-         rs =sentencia.executeQuery(sel); 
-         x=0; 
-         while(rs.next()){ 
-             grillacom.setValueAt(rs.getString("cod"), x, 0); 
-             grillacom.setValueAt(rs.getString("nombre"), x, 1); 
-             grillacom.setValueAt(rs.getString("region"), x, 2); 
-   
-                     x++; 
-             } 
-     sentencia.close(); 
-     }catch(SQLException e){ 
-         JOptionPane.showMessageDialog(this, "Error [MySQLException] al listar datos: " + e.getMessage(),"Error",0); 
-     }catch(Exception e){ 
-         JOptionPane.showMessageDialog(this, "Error [Exception] al listar datos: " + e.getMessage(),"Error",0); 
-     } 
- }