You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Andreas Kyrmegalos <an...@vivodinet.gr> on 2008/06/06 02:42:26 UTC

Database connection not bound to default database schema when authenticating through LDAP?

Hello again,
   I don't know what to make of this. I blame it to the late hour though.

After successfully authenticating user usertest through LDAP to 
establish a connection , I get this message

ERROR 42Y07: Schema 'usertest' does not exist

when executing a statement against the database. The database's schema 
is not 'usertest'. And the database
creator is not 'usertest' either.The same error is reported with other 
user names.

I was under the impression that a database connection is bound to the 
default database schema regardless
of the user name used to connect. Is this a LDAP related thing? Or  is 
it just the right time to hit the sack?

Andreas

Re: Database connection not bound to default database schema when authenticating through LDAP?

Posted by Andreas Kyrmegalos <an...@vivodinet.gr>.
Thanks for taking the time to consider my question and posting such a 
lengthy reply Rick. Luckily, I have found a way to force a default 
schema for my project's hibernate mappings and get things going just 
like I want them to be. For now anyway. Thanks again.

Andreas

Rick Hillegas wrote:
> Hi Andreas,
>
> I can see that for many applications it would be useful to have a 
> concept of a database-wide default schema, that is, a schema that all 
> users start out in when they get a fresh connection. That is not the 
> way Derby works. For Derby, the default schema is user-specific, not 
> database-wide. This is true even in the degenerate case of an embedded 
> application which does not run with authentication turned on: in that 
> case the username defaults to APP and the default schema is APP's schema.
>
> The 2003 SQL standard does not offer any guidance on this topic. 
> According to part 2, section 4.37.2 (SQL-session identification), the 
> default schema of a session is vendor-defined.
>
> I don't remember any deep reason about why Derby has this default 
> behavior. It may be nothing more complicated than the fact that the 
> original programmers were familiar with this default from previous 
> databases which they had worked on.
>
> Some databases let you bind a default schema to a username. See for 
> instance http://msdn.microsoft.com/en-us/library/ms190387.aspx. I 
> think it would be straightforward to build such a mechanism for 
> Derby--although this would take you into session startup logic and the 
> devil could be in the details. I think there are plenty of people 
> around who understand that logic and who could coach a newcomer 
> through this project.
>
> In the meantime, the only workaround I see is for your application to 
> force the schema to a default value when your application hands out 
> connections.
>
> Please pardon me if I have talked past your real concern.
>
> Hope this helps,
> -Rick

Re: Database connection not bound to default database schema when authenticating through LDAP?

Posted by Rick Hillegas <Ri...@Sun.COM>.
Hi Andreas,

I can see that for many applications it would be useful to have a 
concept of a database-wide default schema, that is, a schema that all 
users start out in when they get a fresh connection. That is not the way 
Derby works. For Derby, the default schema is user-specific, not 
database-wide. This is true even in the degenerate case of an embedded 
application which does not run with authentication turned on: in that 
case the username defaults to APP and the default schema is APP's schema.

The 2003 SQL standard does not offer any guidance on this topic. 
According to part 2, section 4.37.2 (SQL-session identification), the 
default schema of a session is vendor-defined.

I don't remember any deep reason about why Derby has this default 
behavior. It may be nothing more complicated than the fact that the 
original programmers were familiar with this default from previous 
databases which they had worked on.

Some databases let you bind a default schema to a username. See for 
instance http://msdn.microsoft.com/en-us/library/ms190387.aspx. I think 
it would be straightforward to build such a mechanism for 
Derby--although this would take you into session startup logic and the 
devil could be in the details. I think there are plenty of people around 
who understand that logic and who could coach a newcomer through this 
project.

In the meantime, the only workaround I see is for your application to 
force the schema to a default value when your application hands out 
connections.

Please pardon me if I have talked past your real concern.

Hope this helps,
-Rick

Andreas Kyrmegalos wrote:
> Thanks Øystein,
>   I was just checking that now too, with builtin authentication. Same 
> result. My impression was that default schemas are attached to the 
> database not the connecting user. So, that since a user has been 
> authenticated and if there are no authorization locks in place there 
> wouldn't be a need to set the schema each time a user connects. 
> Something like a default behavior. But as you said the default 
> behavior is have the connecting username as the starting schema. 
> Thanks again. What I 'm trying to figure out is the rational behind 
> such an approach. If someone could shed some light on this?
>
> Andreas
>
> Øystein Grøvlen wrote:
>>
>> The default schema is the same as the username, regardless of whether 
>> it exists or not.  You can use 'set schema' to switch to another schema.
>>
>


Re: Database connection not bound to default database schema when authenticating through LDAP?

Posted by Andreas Kyrmegalos <an...@vivodinet.gr>.
Thanks Øystein,
   I was just checking that now too, with builtin authentication. Same 
result. My impression was that default schemas are attached to the 
database not the connecting user. So, that since a user has been 
authenticated and if there are no authorization locks in place there 
wouldn't be a need to set the schema each time a user connects. 
Something like a default behavior. But as you said the default behavior 
is have the connecting username as the starting schema. Thanks again. 
What I 'm trying to figure out is the rational behind such an approach. 
If someone could shed some light on this?

Andreas

Øystein Grøvlen wrote:
>
> The default schema is the same as the username, regardless of whether 
> it exists or not.  You can use 'set schema' to switch to another schema.
>


Re: Database connection not bound to default database schema when authenticating through LDAP?

Posted by Øystein Grøvlen <Oy...@Sun.COM>.
Andreas Kyrmegalos wrote:
> Hello again,
>   I don't know what to make of this. I blame it to the late hour though.
> 
> After successfully authenticating user usertest through LDAP to 
> establish a connection , I get this message
> 
> ERROR 42Y07: Schema 'usertest' does not exist
> 
> when executing a statement against the database. The database's schema 
> is not 'usertest'. And the database
> creator is not 'usertest' either.The same error is reported with other 
> user names.
> 
> I was under the impression that a database connection is bound to the 
> default database schema regardless
> of the user name used to connect. Is this a LDAP related thing? Or  is 
> it just the right time to hit the sack?

The default schema is the same as the username, regardless of whether it 
exists or not.  You can use 'set schema' to switch to another schema.

-- 
Øystein