2013-10-22 2 views
0

저는 봄용 MVC, 스프링 시큐리티 및 DerbyDB와 관련된 학교 프로젝트에 참여하고 있습니다.스프링 보안 및 DerbyDB (javaDB)

해결할 수없는 문제가 있으며 도움이 필요합니다. 미리 감사드립니다. 여기

Your login attempt was not successful, try again. 

Reason: PreparedStatementCallback; bad SQL grammar [select LOGIN, PASSWORD from theaterDB."User" where LOGIN = ?]; nested exception is java.sql.SQLException: Column '3' not found. 

콘솔의 메시지입니다 : 내가 로그 - 인 할 (웹 페이지에 인쇄) 실제 사용자와하려고 할 때 다음

는 메시지입니다

SQL error codes for 'Apache Derby' found 
2013-10-22 16:07:16 [DEBUG] SQLErrorCodeSQLExceptionTranslator:283 - Unable to translate SQLException with SQL state 'S0022', error code '0, will now try the fallback translator 
2013-10-22 16:07:16 [DEBUG] SQLStateSQLExceptionTranslator:95 - Extracted SQL state class 'S0' from value 'S0022' 
2013-10-22 16:07:16 [DEBUG] UsernamePasswordAuthenticationFilter:346 - Authentication request failed: org.springframework.security.authentication.AuthenticationServiceException: PreparedStatementCallback; bad SQL grammar [select LOGIN, PASSWORD from theaterDB."User" where LOGIN = ?]; nested exception is java.sql.SQLException: Column '3' not found. 
2013-10-22 16:07:16 [DEBUG] UsernamePasswordAuthenticationFilter:347 - Updated SecurityContextHolder to contain null Authentication 

내 데이터 소스 콩 :

<bean id="dataSource" 
    class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 

    <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" /> 
    <property name="url" value="jdbc:derby:/home/couty/capDB;create=true" /> 
    <property name="username" value="root" /> 
    <property name="password" value="password" /> 
    </bean> 

스프링-security.xml :

<http auto-config="true"> 
     <intercept-url pattern="/welcome*" access="ROLE_USER" /> 
    </http> 

    <authentication-manager> 
     <authentication-provider> 
      <jdbc-user-service data-source-ref="dataSource" 

       users-by-username-query='select LOGIN, PASSWORD from theaterDB."User" where LOGIN = ?'/> 

       <!-- authorities-by-username-query="select u.login, ur.role from User u, UserRole ur where u.id = ur.user_id and u.login =? " --> 

     </authentication-provider> 
    </authentication-manager> 

보시 다시 : /welcome 페이지에 액세스하는 동안 로그인을 시도하고 있습니다. 내가 사용하는 JDBC 드라이버는 오라클이 아닌 DERBY 드라이버입니다. 왜 ? 나는 이미 더비가 있었고 오라클은 잡기가 고통스러워 보였으므로 어떻게 변화하는지 모르겠습니다.

+0

이 여기되는 SQLException의에서 더 많은 정보를 얻을하는 방법에 대한 몇 가지 충고) : http://wiki.apache.org/db-derby/UnwindExceptionChain –

+0

안녕하세요, 고맙습니다. 저는 이것을 내 앱에서 사용할 것입니다. 그러나 스프링 시큐리티 (Spring Security)에서 요청한 내용에 따라 SQL Exception을 어떻게 catch해야하는지 모르겠습니다 ... – ogdabou

+0

"ij"도구를 사용하여 데이터베이스에 직접 연결하고 문제가되는 SQL 문을 직접 실행하십시오. , 당신에게 더 많은 단서를 제공하는 더 나은 오류 디스플레이가 있는지 확인하십시오. 또는 derby.log에서 더 많은 정보를 얻으려면 derby.language.logStatementText = true를 사용하십시오. –

답변

0

쿼리에 "사용 가능"열을 추가해야한다고 생각합니다. 그래서 이와 같은 것 - theaterDB에서 "LOGIN ="을 선택하면 LOGIN = "LOGIN, PASSWORD"를 사용할 수 있습니다. "User"여기서 LOGIN =?

내가 같은 문제를했고 이것이 내 경우에는 일;