Ver Mensaje Individual
  #7 (permalink)  
Antiguo 23/09/2011, 17:54
Avatar de gabrican
gabrican
 
Fecha de Ingreso: junio-2008
Ubicación: Medellin
Mensajes: 89
Antigüedad: 15 años, 11 meses
Puntos: 4
Respuesta: Cerrar conexion con JAVA

Cita:
Iniciado por chuidiang Ver Mensaje
Las llamadas a cerrarConexion() deberías ponerlas en los finally del try-catch. ¿Lo haces así?

Se bueno.
Hola...

Mira tal cual estan....

Código:
public Vector consultarEmpresar(String valor) throws ConnectionException{
		Vector empresas= new Vector();
			
		try{				
			EmpresaDTO empresa;
			PreparedStatement ps;
			ResultSet rslt;
			String sql = null;
			conectar();
			
			sql="select * from tabla";
			ps = conexion.prepareStatement(sql);
			
			ps.setString(1, "%"+valor+"%");
			rslt = ps.executeQuery();			
			
			while (rslt.next()) {
				empresa = new EmpresaDTO();
...
...
...
...
...			}
			
			/* Cierra conexiones establecidas */
			ps.close();
			cerrarConexion();
							
		}catch(SQLException e){
			e.printStackTrace();
		}
			
		return empresas;
	}
__________________
Gabo Duk3
I.S