title: Apache Shiro login failed using JDBC Realm
body: <p>I am trying to connect to oracle DB .
  I want to retrieve list of passwords from data base using the authentication query. Here is my sample shiro.ini file:</p>
  
  <pre><code># password matcher
  passwordMatcher = org.apache.shiro.authc.credential.PasswordMatcher
  passwordService = org.apache.shiro.authc.credential.DefaultPasswordService
  passwordMatcher.passwordService = $passwordService
  
  # datasource
  ds = oracle.jdbc.pool.OracleDataSource
  ds.URL = jdbc:oracle:thin:@matrix-oracle11g:1521:dev11g
  ds.user = cit1am
  ds.password = cit1
  
  jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm
  jdbcRealm.permissionsLookupEnabled = true
  jdbcRealm.authenticationQuery = SELECT USR_PSWD FROM USR
  jdbcRealm.credentialsMatcher = $passwordMatcher
  jdbcRealm.dataSource = $ds
  securityManager.realms = $jdbcRealm
  [users]
  
  [roles]
  
  [urls]
  </code></pre>
  
  <p>Sample code snippet of login:</p>
  
  <pre><code>public class Quickstart {
  
      private static final transient Logger log = LoggerFactory.getLogger(Quickstart.class);
  
  
      public static void main(String[] args) {
      Factory&lt;SecurityManager&gt; factory = new IniSecurityManagerFactory("classpath:shiro.ini");
          SecurityManager securityManager = factory.getInstance();
          SecurityUtils.setSecurityManager(securityManager);
          Subject currentUser = SecurityUtils.getSubject();
  
          // Do some stuff with a Session (no need for a web or EJB container!!!)
          Session session = currentUser.getSession();
          session.setAttribute("someKey", "aValue");
          String value = (String) session.getAttribute("someKey");
          if (value.equals("aValue")) {
              log.info("Retrieved the correct value! [" + value + "]");
          }
          try{
          // let's login the current user so we can check against roles and permissions:
          if (!currentUser.isAuthenticated()) {
  
              UsernamePasswordToken token = new UsernamePasswordToken("cit1am", "cit1")   ;
              token.setRememberMe(true);
              try {
                  currentUser.login(token); //problem occurs here 
                  log.info("inside try block ==========&gt;&gt;" );
              }
  catch (UnknownAccountException uae) {
                  log.info("There is no user with username of " + token.getPrincipal());
              } 
  </code></pre>
  
  <p>I am getting following error:</p>
  
  <pre><code>    [main] ERROR org.apache.shiro.realm.jdbc.JdbcRealm - There was a SQL error while authenticating user [cit1am]
  java.sql.SQLException: Invalid column index
      at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
      at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:271)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:445)
  </code></pre>
  
  <p>Please suggest what i am doing wrong?</p>