Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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();
    }
}
like image 920
rmsluimers Avatar asked Nov 28 '22 06:11

rmsluimers


1 Answers

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.

like image 127
rmsluimers Avatar answered Dec 10 '22 20:12

rmsluimers