PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 20, 2022

[FIXED] SQLSTATE[08001]: [Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: No connection could be made because the target machine actively refused it

 January 20, 2022     doctrine-orm, php, symfony     No comments   

Issue

My doctrine repository code doesn't work, while I am able to access the database and read table data normally.

I get this stacktrace:

EntityManager->getRepository('AppBundle:Person') in src\AppBundle\Controller\PersonViewController.php (line 18) 

  public function indexAction(Request $request) {
         $em = $this->getDoctrine()->getManager();
         $repo = $em->getRepository('AppBundle:Person');
         $persons = $repo->findAll();
         dump($persons);

The person entity model:

Person.php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Class Person
 * @Package AppBundle/Entity
 *
 * @ORM\Entity(repositoryClass="AppBundle\Repository\PersonRepository")
 * @ORM\Table(name="[Person]")
 */
class Person {
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="string", length=4)
     */
    protected $type;
}

In case this is necessary as well, the repo code:

PersonRepository.php

<?php

namespace AppBundle\Repository;

use /** @noinspection PhpUndefinedClassInspection */
    Doctrine\ORM\EntityRepository;

class PersonRepository extends EntityRepository {

    public function create() {
        $entity = new Person();
        $entity->type('WM_B');
        $this->_em->persist($entity);
        $this->_em->flush();
    }
}

Solution

Sql Server Configuration Manager -> Sql Server Network Configuration -> Protocols For -> TCP/IP ->

I changed the following

IpAll
TCP Dynamic Ports 49226
TCP Port

To:

IpAll
TCP Dynamic Ports
TCP Port          1433

Not sure what TCP Dynamic Ports are and why they were configured.



Answered By - rmsluimers
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing