Discussion:
Problems with MS SQL Server and creating merger tokens
Øyvind Harboe
2008-09-25 07:32:27 UTC
Permalink
I had a database connection set up incorrectly, the
database user did not have the correct
access rights to the database. Not that uncommon
when messing around with restoring MS SQL databases...

This cause the code below to return a list of tokens that tables should
be added to the database.

DbMerger merger = new DbMerger();
List<MergerToken> tokens = merger.createMergeTokens(dataNode, dataMap);


I take it that the implementation does not distinguish between failing
to find a database table and not having access to it?


Ideally I'd like the above to throw an exception upon failure...
--
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer
Tore Halset
2008-09-25 07:52:59 UTC
Permalink
Hello.

The merger get the table info using DbLoader that does a
jdbcConnection.getMetaData().getTables() to pick up info on all the
tables. My guess is that the database/jdbc-driver simply does not list
the tables for your misconfigured user.

- Tore.
Post by Øyvind Harboe
I had a database connection set up incorrectly, the
database user did not have the correct
access rights to the database. Not that uncommon
when messing around with restoring MS SQL databases...
This cause the code below to return a list of tokens that tables should
be added to the database.
DbMerger merger = new DbMerger();
List<MergerToken> tokens = merger.createMergeTokens(dataNode, dataMap);
I take it that the implementation does not distinguish between failing
to find a database table and not having access to it?
Ideally I'd like the above to throw an exception upon failure...
--
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer
Øyvind Harboe
2008-09-25 08:15:37 UTC
Permalink
Post by Tore Halset
Hello.
The merger get the table info using DbLoader that does a
jdbcConnection.getMetaData().getTables() to pick up info on all the tables.
My guess is that the database/jdbc-driver simply does not list the tables
for your misconfigured user.
So that means that there *is* no way to distinguish between the case where there
are no tables and where the database user does not have access to enumerate
the tables?

Not even in principle?

Ouch!

I wonder how I might deal with this in my application, especially
since it is intended to
run unsupervised(or by a user not capable of supervising).
--
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer
Scott Anderson
2008-09-25 17:04:05 UTC
Permalink
I'm not familiar with MSSQL, but in MySQL that's definitely the case - both database and table visibility are opt in, not opt out.

-----Original Message-----
From: ***@gmail.com [mailto:***@gmail.com] On Behalf Of Øyvind Harboe
Sent: Thursday, September 25, 2008 4:16 AM
To: ***@cayenne.apache.org
Subject: Re: Problems with MS SQL Server and creating merger tokens
Post by Tore Halset
Hello.
The merger get the table info using DbLoader that does a
jdbcConnection.getMetaData().getTables() to pick up info on all the tables.
My guess is that the database/jdbc-driver simply does not list the tables
for your misconfigured user.
So that means that there *is* no way to distinguish between the case where there
are no tables and where the database user does not have access to enumerate
the tables?

Not even in principle?

Ouch!

I wonder how I might deal with this in my application, especially
since it is intended to
run unsupervised(or by a user not capable of supervising).
--
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer
Øyvind Harboe
2008-09-25 20:28:50 UTC
Permalink
It turned out in my case that the default schema for that user made it,
correctly, be zero tables available.

I.e. there was no error condition and Cayenne did the right thing,
produce the create table merger tokens.
--
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer
Øyvind Harboe
2008-09-26 07:12:53 UTC
Permalink
Post by Øyvind Harboe
It turned out in my case that the default schema for that user made it,
correctly, be zero tables available.
I take this back.

The correct schema was used, but the user did not have the access
rights to enumerate the tables.

Is there any way I can tell Cayenne to fail(throw exception) if it is
not able to
enumerate the tables?
--
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer
Tore Halset
2008-09-26 07:34:08 UTC
Permalink
Post by Øyvind Harboe
Is there any way I can tell Cayenne to fail(throw exception) if it is
not able to enumerate the tables?
The jdbc driver/database did not return those tables in the list of
tables. You can try for your self with some simple jdbc code.

- Tore.

Loading...