You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Daniel John Debrunner <dj...@apache.org> on 2006/09/07 18:34:12 UTC

SQL state 42, access permissions, SQL standard and JDBC 4.0

The SQL standard says that SQL State '42' is for "syntax error or access
rule violation" (section 23.1).

JDBC 4.0 states in section 6.5.1 that "TABLE 6-1 specifies which
NonTransientSQLException subclass must be thrown
for a a given SQLState class value:" and Table 6.1 has these two lines
of interest:

SQL State 42 ->> SQLSyntaxErrorException.
SQL State 'N/A' ->> SQLInvalidAuthorizationException


Derby currently uses SQL State '28' for access rule violations, the SQL
standard says that's for 'invalid authorization specification' and only
used in statements not supported by Derby.


So:

Q1) Should Derby be using '42' for access rule violations?

Q2) If Derby uses '42' for access rule violations should it throw a
SQLSyntaxErrorException, a NonTransientSQLException, a SQLException or
SQLInvalidAuthorizationException?

Dan.




Re: SQL state 42, access permissions, SQL standard and JDBC 4.0

Posted by "Lance J. Andersen" <La...@Sun.COM>.

Daniel John Debrunner wrote:
> Lance J. Andersen wrote:
>
>   
>> Daniel John Debrunner wrote:
>>
>>     
>>> The SQL standard says that SQL State '42' is for "syntax error or access
>>> rule violation" (section 23.1).
>>>
>>> JDBC 4.0 states in section 6.5.1 that "TABLE 6-1 specifies which
>>> NonTransientSQLException subclass must be thrown
>>> for a a given SQLState class value:" and Table 6.1 has these two lines
>>> of interest:
>>>
>>> SQL State 42 ->> SQLSyntaxErrorException.
>>>       
>
> The javadoc SQLSyntaxErrorException for says:
>
> The subclass of SQLException thrown when the SQLState class value is
> '42'. This indicates that the in-progress query has violated SQL syntax
> rules.
>
> This somewhat in-conflict with the SQL Standard.
>
> Can a JDBC driver thrown an exception with SQLState '42' and the
> exception not be a SQLSyntaxErrorException?
>   
Whenever 42 is sent as the SQLState class value it should map to 
SQLSyntaxErrorException.

I need to clarify the javadocs a bit, but it already indicates that this 
is the exception when the value of 42 is returned.


> Thanks,
> Dan.
>
>
>
>   

Re: SQL state 42, access permissions, SQL standard and JDBC 4.0

Posted by "Lance J. Andersen" <La...@Sun.COM>.


> The javadoc SQLSyntaxErrorException for says:
>
> The subclass of SQLException thrown when the SQLState class value is
> '42'. This indicates that the in-progress query has violated SQL syntax
> rules.
>
> This somewhat in-conflict with the SQL Standard.
>
> Can a JDBC driver thrown an exception with SQLState '42' and the
> exception not be a SQLSyntaxErrorException?
>
>
>   
Well we put this part of the spec to bed early 2005 so my memory is 
groggy, but it looks to me that our intent was whenever a SQLState class 
value of 42 occurs, th SQLSyntaxErrorException was thrown which would cover

syntax error or access rule violation


I am just sanity checking this now with my EG and will update the paper 
spec accordingly and have to wait for the first patch of SE 6 to tweak 
the javadocs

-lance

Re: SQL state 42, access permissions, SQL standard and JDBC 4.0

Posted by Daniel John Debrunner <dj...@apache.org>.
Lance J. Andersen wrote:

> 
> 
> Daniel John Debrunner wrote:
> 
>> The SQL standard says that SQL State '42' is for "syntax error or access
>> rule violation" (section 23.1).
>>
>> JDBC 4.0 states in section 6.5.1 that "TABLE 6-1 specifies which
>> NonTransientSQLException subclass must be thrown
>> for a a given SQLState class value:" and Table 6.1 has these two lines
>> of interest:
>>
>> SQL State 42 ->> SQLSyntaxErrorException.

The javadoc SQLSyntaxErrorException for says:

The subclass of SQLException thrown when the SQLState class value is
'42'. This indicates that the in-progress query has violated SQL syntax
rules.

This somewhat in-conflict with the SQL Standard.

Can a JDBC driver thrown an exception with SQLState '42' and the
exception not be a SQLSyntaxErrorException?

Thanks,
Dan.




Re: SQL state 42, access permissions, SQL standard and JDBC 4.0

Posted by "Lance J. Andersen" <La...@Sun.COM>.

Daniel John Debrunner wrote:
> The SQL standard says that SQL State '42' is for "syntax error or access
> rule violation" (section 23.1).
>
> JDBC 4.0 states in section 6.5.1 that "TABLE 6-1 specifies which
> NonTransientSQLException subclass must be thrown
> for a a given SQLState class value:" and Table 6.1 has these two lines
> of interest:
>
> SQL State 42 ->> SQLSyntaxErrorException.
> SQL State 'N/A' ->> SQLInvalidAuthorizationException
>   
That is a typo.  The javadocs indicate 28 for 
SQLInvalidAuthorizationException.


>
> Derby currently uses SQL State '28' for access rule violations, the SQL
> standard says that's for 'invalid authorization specification' and only
> used in statements not supported by Derby.
>
>
> So:
>
> Q1) Should Derby be using '42' for access rule violations?
>
> Q2) If Derby uses '42' for access rule violations should it throw a
> SQLSyntaxErrorException, a NonTransientSQLException, a SQLException or
> SQLInvalidAuthorizationException?
>
> Dan.
>
>
>
>   

Re: SQL state 42, access permissions, SQL standard and JDBC 4.0

Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
Mamta Satoor <ms...@gmail.com> writes:

> Does 'N/A' in JDBC 4.0 spec(Table 6.1) mean Derby is free to choose the the
> SQL State number? If so, then I think we shold definitely use '42' for access
> rule violation since that will satisfy SQL specification too.
>  
> Also it seems for access rule violation, SQLInvalidAuthorizationException
> would be the correct exception to throw.

I think the last sentence is missing a not. I found this description at
http://download.java.net/jdk6/docs/api/java/sql/SQLInvalidAuthorizationSpecException.html:

  The subclass of SQLException thrown when the SQLState class value is
  '28'. This indicated that the authorization credentials presented
  during connection establishment are not valid.

Sounds like a different kind of access violation.

> I think there is a trick to use same SQL state for 2 different
> exceptions in Derby code, but I can't recall how to do it.

You can separate between them with a suffix. From SQLState.java:

    String NOT_IMPLEMENTED = "0A000.S";
    String JDBC_METHOD_NOT_IMPLEMENTED = "0A000.S.1";
    String JDBC_METHOD_NOT_SUPPORTED_BY_SERVER = "0A000.S.2";
    (...)

-- 
Knut Anders

Re: SQL state 42, access permissions, SQL standard and JDBC 4.0

Posted by Daniel John Debrunner <dj...@apache.org>.
Mamta Satoor wrote:

> Does 'N/A' in JDBC 4.0 spec(Table 6.1) mean Derby is free to choose the the
> SQL State number? If so, then I think we shold definitely use '42'
> for access rule violation since that will satisfy SQL specification too.
> 
> Also it seems for access rule violation, SQLInvalidAuthorizationException
> would be the correct exception to throw.

Given that Lance just said '28' is for SQLInvalidAuthorizationException
and the javadoc says:

"The subclass of SQLException thrown when the SQLState class value is
'28'. This indicated that the authorization credentials presented during
connection establishment are not valid."

It doesn't seem that SQLInvalidAuthorizationException is correct for
access violations.

Dan.





Re: SQL state 42, access permissions, SQL standard and JDBC 4.0

Posted by Mamta Satoor <ms...@gmail.com>.
Does 'N/A' in JDBC 4.0 spec(Table 6.1) mean Derby is free to choose the the
SQL State number? If so, then I think we shold definitely use '42'
for access rule violation since that will satisfy SQL specification too.

Also it seems for access rule violation, SQLInvalidAuthorizationException
would be the correct exception to throw. I think there is a trick to
use same SQL state for 2 different exceptions in Derby code, but I can't
recall how to do it.

Mamta

On 9/7/06, Yip Ng <yi...@gmail.com> wrote:
>
> For Q1)  I think it should use SQLSTATE class code of '42' instead of
> '28'.
> class code '42' is used for syntax error or access rule violation
> according to the
> SQL spec.
>
>
> Yip
>
>
> On 9/7/06, Daniel John Debrunner <dj...@apache.org> wrote:
> >
> > The SQL standard says that SQL State '42' is for "syntax error or access
> > rule violation" (section 23.1).
> >
> > JDBC 4.0 states in section 6.5.1 that "TABLE 6-1 specifies which
> > NonTransientSQLException subclass must be thrown
> > for a a given SQLState class value:" and Table 6.1 has these two lines
> > of interest:
> >
> > SQL State 42 ->> SQLSyntaxErrorException.
> > SQL State 'N/A' ->> SQLInvalidAuthorizationException
> >
> >
> > Derby currently uses SQL State '28' for access rule violations, the SQL
> > standard says that's for 'invalid authorization specification' and only
> > used in statements not supported by Derby.
> >
> >
> > So:
> >
> > Q1) Should Derby be using '42' for access rule violations?
> >
> > Q2) If Derby uses '42' for access rule violations should it throw a
> > SQLSyntaxErrorException, a NonTransientSQLException, a SQLException or
> > SQLInvalidAuthorizationException?
> >
> > Dan.
> >
> >
> >
> >
>

Re: SQL state 42, access permissions, SQL standard and JDBC 4.0

Posted by Yip Ng <yi...@gmail.com>.
For Q1)  I think it should use SQLSTATE class code of '42' instead of '28'.

class code '42' is used for syntax error or access rule violation according
to the
SQL spec.

Yip

On 9/7/06, Daniel John Debrunner <dj...@apache.org> wrote:
>
> The SQL standard says that SQL State '42' is for "syntax error or access
> rule violation" (section 23.1).
>
> JDBC 4.0 states in section 6.5.1 that "TABLE 6-1 specifies which
> NonTransientSQLException subclass must be thrown
> for a a given SQLState class value:" and Table 6.1 has these two lines
> of interest:
>
> SQL State 42 ->> SQLSyntaxErrorException.
> SQL State 'N/A' ->> SQLInvalidAuthorizationException
>
>
> Derby currently uses SQL State '28' for access rule violations, the SQL
> standard says that's for 'invalid authorization specification' and only
> used in statements not supported by Derby.
>
>
> So:
>
> Q1) Should Derby be using '42' for access rule violations?
>
> Q2) If Derby uses '42' for access rule violations should it throw a
> SQLSyntaxErrorException, a NonTransientSQLException, a SQLException or
> SQLInvalidAuthorizationException?
>
> Dan.
>
>
>
>