2 Replies Latest reply on Jun 25, 2004 9:21 AM by pnevado

    DatabaseServerLoginModule SQL failure: Column Index out of r

    pnevado

      I am afraid that this is not a clever question, but I have not found yet an answer.
      With MySql 4.0.18, jdbc driver version 3.0.14 and JBoss 3.2.4, I get the followin excepcion:

      java.sql.SQLException: Column Index out of range ( 2 > 1).
       at com.mysql.jdbc.ResultSet.getString(ResultSet.java:1783)


      with the following two queries in my login module:

      <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule"
       flag="required">
       <module-option name="dsJndiName">java:/mysqlDS</module-option>
       <module-option name="principalsQuery">select password from vivoen.usuario where id_usuario=?</module-option>
       <module-option name="rolesQuery">select id_servicio from vivoen.registro where id_usuario=? AND id_website=1 AND (fecha_fin >= NOW() OR fecha_fin IS NULL)</module-option>
       </login-module>


      I know literally what the exception means, but I am not able to guess why it is thrown in this particular case. Any help about the problem or about any method to find out the actual query that the DatabaseServerLoginModule is using is most wellcome.

        • 1. Re: DatabaseServerLoginModule SQL failure: Column Index out
          blackers

          your roles query is supposed to return two columns not one as your SQL statement is suggesting.

          The first table column should be the Role and the second the RoleGroup,
          from your query

          <module-option name="rolesQuery">select id_servicio from vivoen.registro where id_usuario=? AND id_website=1 AND (fecha_fin >= NOW() OR fecha_fin IS NULL)</module-option>


          I assume that id_servicio is the role, but you are not asking for a RoleGroup. From what I have found the Value for RoleGroup should be "Roles" so you could try.
          <module-option name="rolesQuery">select id_servicio 'Role', "Roles" AS RoleGroup from vivoen.registro where id_usuario=? AND id_website=1 AND (fecha_fin >= NOW() OR fecha_fin IS NULL)</module-option>


          Hope this helps
          Mat

          • 2. Re: DatabaseServerLoginModule SQL failure: Column Index out
            pnevado

            Thanks.

            It works now, just adding the code you suggested.
            Regards.