PHP - PDOException: SQLSTATE[08001]: [Microsoft][ODBC Driver 13 for SQL Server]SSL Provider: Se ha forzado

 
Vista:
sin imagen de perfil

PDOException: SQLSTATE[08001]: [Microsoft][ODBC Driver 13 for SQL Server]SSL Provider: Se ha forzado

Publicado por Mauricio (3 intervenciones) el 20/12/2022 00:05:18
Que tal amigos sigo teniendo el mismo problema el error es el siguiente:

No se ha podido realizar la conexión con la base de datos PDOException: SQLSTATE[08001]: [Microsoft][ODBC Driver 13 for SQL Server]SSL Provider: Se ha forzado la interrupción de una conexión existente por el host remoto.

Ya actualice los dll y mi código es este
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
class DataBaseSQLServer
{
private $bd_servidor;
private $bd_usuario;
private $bd_password;
private $bd_nombre;
protected $bd_conexion;
protected $tipo_conexion;
 
function __construct() {
$tipo_conexion = 'remoto';
 
$conexion['remoto'] = array ('bd_host' => '192.168.1.228\AWSERV', 'bd_nombre'=>'MEGADATA','bd_usuario'=>'root', 'bd_password'=>'root' );
 
$this->bd_servidor = $conexion[$tipo_conexion]['bd_host'];
$this->bd_nombre = $conexion[$tipo_conexion]['bd_nombre'];
$this->bd_usuario = $conexion[$tipo_conexion]['bd_usuario'];
$this->bd_password = $conexion[$tipo_conexion]['bd_password'];
 
}
 
public function conectarBD(){
try {
 
$this->bd_conexion = new PDO("sqlsrv:Server=$this->bd_servidor; Database=$this->bd_nombre; ConnectionPooling=0;", $this->bd_usuario, $this->bd_password); // ESTA ES LA LINEA 30
$this->bd_conexion->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $this->bd_conexion;
} catch (PDOException $exc) {
echo 'No se ha podido realizar la conexión con la base de datos '.$exc;
}
}
public function desconectarBD(){
$this->bd_conexion = '';
unset($this->bd_conexion);
}
 
public function getBD_Conexion(){
return $this->bd_conexion;
}
 
protected function ejecutarConsulta($consulta_sql, $array_datos, $con_parametros, $tipo_consulta)
{
 
$query = $this->conectarBD()->prepare($consulta_sql); //Prepara la consulta
if($con_parametros == 'n' || $con_parametros == 'N'){
$query->execute(); //Ejecuta la consulta
}
else{
$query->execute($array_datos);
}
 
if($tipo_consulta == 'n') {
$resultado = $query->fetchAll();
$this->desconectarBD();
}
elseif($tipo_consulta =='a'){
$resultado = $query->fetch(PDO::FETCH_ASSOC);
$this->desconectarBD();
}
elseif($tipo_consulta =='at'){
// se agrego el try
try {
$resultado = $query->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $err) {
echo 'No se ha podido realizar la asociación ';
}
$this->desconectarBD();
}
 
return $resultado;
}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de John
Val: 91
Ha disminuido 1 puesto en PHP (en relación al último mes)
Gráfica de PHP

PDOException: SQLSTATE[08001]: [Microsoft][ODBC Driver 13 for SQL Server]SSL Provider: Se ha forzado

Publicado por John (6 intervenciones) el 22/12/2022 16:38:59
Tienes habilitado el uso de PDO y ODBC en el php.ini ?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar