title: DBAL connection as service throws error
body: <p>I followed <a href="https://stackoverflow.com/questions/22426444/symfony-config-component-and-service-for-doctrine-dbal/22427451#22427451"><strong>this SO answer</strong></a> to build my DBAL connection as service.</p>
  
  <p>I have the following configuration:</p>
  
  <p>In my service class file "Doctrine.php", I have</p>
  
  <pre><code>&lt;?php
  namespace Acme\BookBundle\Services;
  
  use Doctrine\Common\ClassLoader;
  use Doctrine\DBAL\Configuration;
  use Doctrine\DBAL\DriverManager;
  
  
  class Doctrine
  {
      // Just rename __construct to create and make it static
      static function create(){
          $doctrineLoader = new ClassLoader('Doctrine');
          $doctrineLoader-&gt;register();
  
          $doctrineConfig = new Configuration();
          $doctrineParams = [
              'driver' =&gt; 'pdo_mysql',
              'dbname' =&gt; 'book_enterprise_hub',
              'host' =&gt; 'localhost',
              'user' =&gt; 'root',
              'password' =&gt; '',
          ];
          return DriverManager::getConnection($doctrineParams, $doctrineConfig);
      }
  
  }
  ?&gt;
  </code></pre>
  
  <p>In my services.yml, I have the following:</p>
  
  <pre><code>parameters:
      dbal_connection: book_enterprise_hub
  
  services:
      doctrine:
          class: Doctrine\DBAL\Connection
          factory_class:  'Acme\BookBundle\Services\Doctrine'
          factory_method: 'create'
  </code></pre>
  
  <p>In my CompanyController.php, I have the following code,</p>
  
  <pre><code>&lt;?php
  use Acme\BookBundle\Services\Doctrine;
  
  class CompanyController extends Controller
  {
      public function createAction()
      {
          $con = $this-&gt;get('doctrine');
          $sqlQuery = "CREATE TABLE book_info (id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, label TEXT, created_on DATETIME) ENGINE = INNODB";
          $stmt = $con-&gt;prepare($sqlQuery);
          $stmt-&gt;execute();
      }
  }   
  </code></pre>
  
  <p>When calling this line <strong>$con->prepare($sqlQuery)</strong>,</p>
  
  <p>I get the following error,</p>
  
  <p><strong>Attempted to call method "prepare" on class "Doctrine\Bundle\DoctrineBundle\Registry" in C:\wamp\www\symfony\src\Acme\BookBundle\Controller\CompanyController.php</strong></p>
  
  <p>Actually, I am using factory method for getting DBAL connection as service but kept getting this error. Can I write parameters in service.yml as given above or I should write in parameters.yml only? What am I doing wrong? </p>