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 Trejkaz <tr...@trypticon.org> on 2011/12/15 01:51:26 UTC

Period in username when using a DataSource

Hi all.

If I do this (using version 10.8.2.2):

    ClientConnectionPoolDataSource ds = new ClientConnectionPoolDataSource();
    ds.setServerName("derby");
    ds.setPortNumber(2000);
    ds.setDatabaseName("db");
    ds.setUser("john.smith");

This eventually results in an error on the server side:

    ERROR 28502: The user name 'john.smith' is not valid.
           at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:286)
           at org.apache.derby.iapi.util.IdUtil.getUserAuthorizationId(IdUtil.java:570)
           at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.initialize(GenericLanguageConnectionContext.java:381)
           at org.apache.derby.impl.db.BasicDatabase.setupConnection(BasicDatabase.java:295)

After a bit of research, I read that usernames with a dot are fine in
a database *URL* as long as you quote them.  But I'm *not* using a URL
here, I'm using a setter on a bean.  So I would be expecting the
library to properly quote a string if it deems that the value I passed
in needs it.

Yet Derby doesn't appear to be doing this.  Is this a bug?

TX

Re: Period in username when using a DataSource

Posted by Trejkaz <tr...@trypticon.org>.
On Fri, Dec 16, 2011 at 10:41 AM, Dag H. Wanvik <da...@oracle.com> wrote:
> Trejkaz <tr...@trypticon.org> writes:
>
>> Yet Derby doesn't appear to be doing this.  Is this a bug?
>
> A username must be a valid SQL identifier in Derby. If you want to use
> "."  inside one, you need to quite it. In Java, "\"john.smith\"", in
> SQL, e.g in a GRANT statement: GRANT xxx TO "john.smith",
>
> Note that quoted identifier must have the correct case (case is
> significant then).

Yeah, I read about that, but the surprising thing to me is that I have
to quote it even when using a bean-like API which it seems should be
doing it for me...

But I guess as long as it will never start doing it, it's safe to
quote it myself.

TX

Re: Period in username when using a DataSource

Posted by "Dag H. Wanvik" <da...@oracle.com>.
Trejkaz <tr...@trypticon.org> writes:

> Yet Derby doesn't appear to be doing this.  Is this a bug?

A username must be a valid SQL identifier in Derby. If you want to use
"."  inside one, you need to quite it. In Java, "\"john.smith\"", in
SQL, e.g in a GRANT statement: GRANT xxx TO "john.smith",

Note that quoted identifier must have the correct case (case is
significant then).

Hope this helps,
Dag

>
> TX