Announcement Announcement Module
Collapse
No announcement yet.
SQL Exeception while trying to login Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SQL Exeception while trying to login

    Hi,
    I am trying to authenticate against table like this:
    Code:
    	<bean id="jdbcDaoImpl"
    		class="net.sf.acegisecurity.providers.dao.jdbc.JdbcDaoImpl">
    		<property name="dataSource">
    			<ref bean="dataSource" />
    		</property>
    		<property name="usersByUsernameQuery">
    				<value>
    				SELECT username, password FROM
    				Users WHERE username=?
    			</value>
    		</property>
    			<property name="authoritiesByUsernameQuery">
    			<value>
    				SELECT username, authority FROM
    				authorities WHERE username=?
    			</value>
    		</property>
    	</bean>
    When trying to login I get this stack trace:

    2005-10-07 21:01:14,968 [http-8080-Processor24] INFO - PreparedStatementCallback; uncategorized SQLException for SQL [
    SELECT username, password FROM
    Users WHERE username=?
    ]; SQL state [S1009]; error code [0]; Column Index out of range, 3 > 2. ; nested exception is java.sql.SQLException: Column Index out of range, 3 > 2. ; nested exception is org.springframework.jdbc.UncategorizedSQLException : PreparedStatementCallback; uncategorized SQLException for SQL [
    SELECT username, password FROM
    Users WHERE username=?
    ]; SQL state [S1009]; error code [0]; Column Index out of range, 3 > 2. ; nested exception is java.sql.SQLException: Column Index out of range, 3 > 2.
    Could anyone explain me why this happens?
    Normally the authentication should work without providing special sql statements because my table structure is nearly the same as provided on acegis page, except for some additional columns.

    Could anyone help me?

    Thanks a lot.

    Johannes

  • #2
    Hi,
    I made some changes and switched back to the normal way like this:

    Code:
       <bean id="authenticationDao" class="net.sf.acegisecurity.providers.dao.jdbc.JdbcDaoImpl">
          <property name="dataSource"><ref bean="dataSource"/></property>
       </bean>
    Now I get the following log:

    005-10-08 10:54:09,593 [http-8080-Processor23] DEBUG - Cache hit: false; username: Joee
    2005-10-08 10:54:09,593 [http-8080-Processor23] DEBUG - Executing SQL query [SELECT username,password,enabled FROM users WHERE username = ?]
    2005-10-08 10:54:09,593 [http-8080-Processor23] DEBUG - Fetching JDBC Connection from DataSource
    2005-10-08 10:54:09,593 [http-8080-Processor23] DEBUG - Setting SQL statement parameter value: column index 1, parameter value [Joee], value class [java.lang.String], SQL type 12
    2005-10-08 10:54:09,593 [http-8080-Processor23] DEBUG - Returning JDBC Connection to DataSource
    2005-10-08 10:54:09,593 [http-8080-Processor23] DEBUG - Executing SQL query [SELECT username,authority FROM authorities WHERE username = ?]
    2005-10-08 10:54:09,593 [http-8080-Processor23] DEBUG - Fetching JDBC Connection from DataSource
    2005-10-08 10:54:09,593 [http-8080-Processor23] DEBUG - Setting SQL statement parameter value: column index 1, parameter value [Joee], value class [java.lang.String], SQL type 12
    2005-10-08 10:54:09,593 [http-8080-Processor23] DEBUG - Returning JDBC Connection to DataSource
    2005-10-08 10:54:09,609 [http-8080-Processor23] DEBUG - Publishing event in context [Root WebApplicationContext]: net.sf.acegisecurity.providers.dao.event.Authentic ationFailureUsernameNotFoundEvent[source=net.sf.acegisecurity.providers.UsernamePass wordAuthenticationToken@3eeab3: Username: Joee; Password: [PROTECTED]; Authenticated: false; Details: null; Not granted any authorities]
    2005-10-08 10:54:09,609 [http-8080-Processor23] WARN - Authentication failed due to nonexistent username: Joee; details: null
    2005-10-08 10:54:09,609 [http-8080-Processor23] INFO - Bad credentials presented
    What's confusing me is, that using exactly the same query in the Mysql Query Browser returns the row that exists.

    So could anyone tell me what's wrong?

    Comment


    • #3
      Okay I found the problem in the table authorities there was missing the entry...

      *ggrrr**

      Thanks for all helping comments
      Special thanks @ Johannens :lol:


      Regards!

      Nice Weekend!

      Comment

      Working...
      X