Unix Technical Forum

CachedRowSetXImpl() and PostgreSQL

This is a discussion on CachedRowSetXImpl() and PostgreSQL within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> I am having some trouble getting CachedRowSetXImpl() to work with postgresql-8.1-407.jdbc3.jar in this part of a SessionBean CachedRowSetXImpl crsx ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 12:18 AM
=?ISO-8859-1?Q?Poul_M=F8ller_Hansen?=
 
Posts: n/a
Default CachedRowSetXImpl() and PostgreSQL

I am having some trouble getting CachedRowSetXImpl() to work with
postgresql-8.1-407.jdbc3.jar in
this part of a SessionBean

CachedRowSetXImpl crsx = new CachedRowSetXImpl();
crsx.setDataSourceName("java:comp/env/jdbc/MyDataSource");
crsx.setTableName("table");
crsx.setCommand("SELECT ALL id, url FROM my.table ");


Getting the data is no problem, but when updating it's not using the
correct tablename
I have tried crsx.setTableName("my.table");
But then I get a "No columns in table" as this statement will not find
the table "my.table":
-----
SELECT
n.nspname,c.relname,a.attname,a.atttypid,a.attnotn ull,a.atttypmod,a.attlen,a.attnum,def.adsrc,dsc.de scription
FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_class c ON
(c.relnamespace = n.oid) JOIN pg_catalog.pg_attribute a ON
(a.attrelid=c.oid) LEFT JOIN pg_catalog.pg_attrdef def ON
(a.attrelid=def.adrelid AND a.attnum = def.adnum) LEFT JOIN
pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum =
dsc.objsubid) LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid
AND dc.relname='pg_class') LEFT JOIN pg_catalog.pg_namespace dn ON
(dc.relnamespace=dn.oid AND dn.nspname='pg_catalog') WHERE a.attnum > 0
AND NOT a.attisdropped AND c.relname LIKE 'my.table' AND a.attname
LIKE 'id' ORDER BY nspname,relname,attnum
-----

It should have used the name "table" instead of "my.table"
Without the schema name, I get a "relation not found.

Then I tried adding this:
crsx.setSchemaName("my");

But then It stops in an exception with no error message right after
setting transaction level:
-----
StandardContext[/MyApp]Error Description
java.lang.RuntimeException
at
com.sun.data.provider.impl.CachedRowSetDataProvide r.commitChanges(CachedRowSetDataProvider.java:878)
-----

How is it possible getting it to work ?


Thanks,
Poul



---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-16-2008, 12:18 AM
=?ISO-8859-1?Q?Poul_M=F8ller_Hansen?=
 
Posts: n/a
Default Re: CachedRowSetXImpl() and PostgreSQL


> I am having some trouble getting CachedRowSetXImpl() to work with
> postgresql-8.1-407.jdbc3.jar in
> this part of a SessionBean
>

Is this list dead ?

Have found a workaround.
Avoid using schema names and set the search path:

SHOW search_path
ALTER USER me SET search_path TO public,my,anotherschema


Poul


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-16-2008, 12:18 AM
Markus Schaber
 
Posts: n/a
Default Re: CachedRowSetXImpl() and PostgreSQL

Hi, Poul,

Poul Møller Hansen wrote:
>
>> I am having some trouble getting CachedRowSetXImpl() to work with
>> postgresql-8.1-407.jdbc3.jar in
>> this part of a SessionBean
>>

> Is this list dead ?


Not yet, but e-mail is no real-time media. You should expect one or two
business days delay, as most people here are reading in their free time.

HTH,
Markus

--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-16-2008, 12:18 AM
=?ISO-8859-15?Q?Poul_M=F8ller_Hansen?=
 
Posts: n/a
Default Re: CachedRowSetXImpl() and PostgreSQL


>> Is this list dead ?
>>

Of course I wasn't expecting an instant answer. I was just wondering
that there hasn't been other emails in the period.

Poul


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-16-2008, 12:18 AM
=?ISO-8859-1?Q?Poul_M=F8ller_Hansen?=
 
Posts: n/a
Default Re: CachedRowSetXImpl() and PostgreSQL


>
> If you could at least track it down to a particular metadata call that
> the driver is incorrectly implementing that might get a response, but
> as it is there is nothing I can debug here.

Isn't that what I did ?
Here is all statements when setting the table name to "my.table":
-----
SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED;
BEGIN;
SELECT t.typlen FROM pg_catalog.pg_type t, pg_catalog.pg_namespace n
WHERE t.typnamespace=n.oid AND t.typname='name' AND n.nspname='pg_catalog';
SELECT
n.nspname,c.relname,a.attname,a.atttypid,a.attnotn ull,a.atttypmod,a.attlen,a.attnum,def.adsrc,dsc.de scription
FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_class c ON
(c.relnamespace = n.oid) JOIN pg_catalog.pg_attribute a ON
(a.attrelid=c.oid) LEFT JOIN pg_catalog.pg_attrdef def ON
(a.attrelid=def.adrelid AND a.attnum = def.adnum) LEFT JOIN
pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum =
dsc.objsubid) LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid
AND dc.relname='pg_class') LEFT JOIN pg_catalog.pg_namespace dn ON
(dc.relnamespace=dn.oid AND dn.nspname='pg_catalog') WHERE a.attnum > 0
AND NOT a.attisdropped AND c.relname LIKE 'my.table' AND a.attname
LIKE 'id' ORDER BY nspname,relname,attnum;
SELECT
n.nspname,c.relname,a.attname,a.atttypid,a.attnotn ull,a.atttypmod,a.attlen,a.attnum,def.adsrc,dsc.de scription
FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_class c ON
(c.relnamespace = n.oid) JOIN pg_catalog.pg_attribute a ON
(a.attrelid=c.oid) LEFT JOIN pg_catalog.pg_attrdef def ON
(a.attrelid=def.adrelid AND a.attnum = def.adnum) LEFT JOIN
pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum =
dsc.objsubid) LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid
AND dc.relname='pg_class') LEFT JOIN pg_catalog.pg_namespace dn ON
(dc.relnamespace=dn.oid AND dn.nspname='pg_catalog') WHERE a.attnum > 0
AND NOT a.attisdropped AND c.relname LIKE 'my.table' AND a.attname
LIKE 'url' ORDER BY nspname,relname,attnum;
ROLLBACK;
SHOW TRANSACTION ISOLATION LEVEL;
-----

It will not fine "my.table" as it should have been "table" only.
If I set the tablename to "table" the result is this:

-----
SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED;
BEGIN;
SELECT t.typlen FROM pg_catalog.pg_type t, pg_catalog.pg_namespace n
WHERE t.typnamespace=n.oid AND t.typname='name' AND n.nspname='pg_catalog';
SELECT
n.nspname,c.relname,a.attname,a.atttypid,a.attnotn ull,a.atttypmod,a.attlen,a.attnum,def.adsrc,dsc.de scription
FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_class c ON
(c.relnamespace = n.oid) JOIN pg_catalog.pg_attribute a ON
(a.attrelid=c.oid) LEFT JOIN pg_catalog.pg_attrdef def ON
(a.attrelid=def.adrelid AND a.attnum = def.adnum) LEFT JOIN
pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum =
dsc.objsubid) LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid
AND dc.relname='pg_class') LEFT JOIN pg_catalog.pg_namespace dn ON
(dc.relnamespace=dn.oid AND dn.nspname='pg_catalog') WHERE a.attnum > 0
AND NOT a.attisdropped AND c.relname LIKE 'table' AND a.attname LIKE
'id' ORDER BY nspname,relname,attnum;
SELECT
n.nspname,c.relname,a.attname,a.atttypid,a.attnotn ull,a.atttypmod,a.attlen,a.attnum,def.adsrc,dsc.de scription
FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_class c ON
(c.relnamespace = n.oid) JOIN pg_catalog.pg_attribute a ON
(a.attrelid=c.oid) LEFT JOIN pg_catalog.pg_attrdef def ON
(a.attrelid=def.adrelid AND a.attnum = def.adnum) LEFT JOIN
pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum =
dsc.objsubid) LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid
AND dc.relname='pg_class') LEFT JOIN pg_catalog.pg_namespace dn ON
(dc.relnamespace=dn.oid AND dn.nspname='pg_catalog') WHERE a.attnum > 0
AND NOT a.attisdropped AND c.relname LIKE 'table' AND a.attname LIKE
'url' ORDER BY nspname,relname,attnum;
SELECT id, url FROM table WHERE id = $1 AND url = $2

2006-09-21 14:30:40 CEST - ERROR: relation "table" does not exist

ROLLBACK;
SHOW TRANSACTION ISOLATION LEVEL;
-----

Please let me know if more is needed.


Poul



---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-16-2008, 12:18 AM
Oliver Jowett
 
Posts: n/a
Default Re: CachedRowSetXImpl() and PostgreSQL

Poul Møller Hansen wrote:

> Please let me know if more is needed.


What we need to know is what is the metadata call being made to the
driver and how do the results differ from what is expected?

BTW, it's possible to have a table called "my.table" (where "my." is
part of the table name, not a schema prefix) so the driver seems to be
doing the right thing if it is being asked about tables called
"my.table" by the RowSet .. But that's why we need to know what metadata
call is being made.

I think finding out why setSchemaName on your rowset does not work is
the first step, that RuntimeException tells me nothing about the real
cause of the problem.

-O

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-16-2008, 12:18 AM
=?ISO-8859-1?Q?Poul_M=F8ller_Hansen?=
 
Posts: n/a
Default Re: CachedRowSetXImpl() and PostgreSQL


> What we need to know is what is the metadata call being made to the
> driver and how do the results differ from what is expected?
>

That's pretty much hidden behind the curtains in the Java classes. How
can I log that ?

> BTW, it's possible to have a table called "my.table" (where "my." is
> part of the table name, not a schema prefix) so the driver seems to be
> doing the right thing if it is being asked about tables called
> "my.table" by the RowSet .. But that's why we need to know what
> metadata call is being made.
>

my is the schema name. I have tried 3 setups:
1. setting setTableName("my.table");
2. setTableName("table");
3. setSchemaName("my"); setTableName("table");

And none of them works. When getting the metadata from pg_catalog the
schema name must be left out
and when doing update the schema name must be included or it can't find
the relation.
It's like the setSchemaName has no effect
> I think finding out why setSchemaName on your rowset does not work is
> the first step, that RuntimeException tells me nothing about the real
> cause of the problem.

Exactly, but I'm clueless how.


Poul


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-16-2008, 12:18 AM
Oliver Jowett
 
Posts: n/a
Default Re: CachedRowSetXImpl() and PostgreSQL

Poul Møller Hansen wrote:
>
>> What we need to know is what is the metadata call being made to the
>> driver and how do the results differ from what is expected?
>>

> That's pretty much hidden behind the curtains in the Java classes. How
> can I log that ?


Well, we have exactly the same problem, without seeing the code that
calls the driver it is very difficult to know if the fault lies with the
driver or the calling code.

I think there are some intercepting JDBC driver wrappers that might help
you with the "what is the metadata call" bit (I can't remember the name
of one offhand) but the "how do the results differ" requires some
knowledge of what the calling code is expecting.. which probably means
"contact the implementor of your RowSet".

>> BTW, it's possible to have a table called "my.table" (where "my." is
>> part of the table name, not a schema prefix) so the driver seems to be
>> doing the right thing if it is being asked about tables called
>> "my.table" by the RowSet .. But that's why we need to know what
>> metadata call is being made.
>>

> my is the schema name. I have tried 3 setups:
> 1. setting setTableName("my.table");
> 2. setTableName("table");
> 3. setSchemaName("my"); setTableName("table")


I would expect (3) to be what you need.

>> I think finding out why setSchemaName on your rowset does not work is
>> the first step, that RuntimeException tells me nothing about the real
>> cause of the problem.

>
> Exactly, but I'm clueless how.


Again I think this is going to be "talk to the RowSet implementor"
unfortunately.

-O

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:35 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com