title: org.postgresql.util.PSQLException: The column index is out of range: 3, number of columns: 2
body: <p>I decided to modify my application by adding there authentication using <code>spring security</code> and database. Before I was using plain authentication with <code>user</code> and <code>password</code> in XML. It worked fine.</p>
  
  <p>My <code>authentication-manager</code> looks like this</p>
  
  <pre><code>&lt;authentication-manager&gt;
      &lt;authentication-provider&gt;
          &lt;jdbc-user-service data-source-ref="dataSource"
          users-by-username-query="select username, password from pmc.username_password where username=?;"
          authorities-by-username-query="select a.username, b.role from pmc.username_password a, pmc.username_role b where a.username = b.username and a.username=?;" /&gt;
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  </code></pre>
  
  <p>But when I make an attempt to authenticate I've got exception</p>
  
  <pre><code>org.springframework.security.authentication.InternalAuthenticationServiceException: PreparedStatementCallback; SQL [select u
  sername, password from pmc.username_password where username=?;]; The column index is out of range: 3, number of columns: 2.;
   nested exception is org.postgresql.util.PSQLException: The column index is out of range: 3, number of columns: 2.
  </code></pre>
  
  <p>What is wrong in my <code>sql</code> syntax in XML file?</p>