pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedDatabaseMetaData.getCatalogs()
12+ messages / 6 participants
[nested] [flat]
* DatabaseMetaData.getCatalogs()
@ 2001-07-06 22:33 jason@netspade.com
0 siblings, 0 replies; 12+ messages in thread
From: jason@netspade.com @ 2001-07-06 22:33 UTC (permalink / raw)
Hi,
Is there a reason why getCatalogs() is not supported in the JDBC driver? First of all, what is the definition of a catalog? The MySQL JDBC driver simply returns a list of the databases so a simple select datname from pg_database; would do the same thing. However there is probably a reason for this and I would be grateful if you would explain.
I'm writing a database admin tool and so far I've made my own Connector class to implement things like this.
Thanks,
Jason Davies
jason@netspade.com
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: DatabaseMetaData.getCatalogs()
@ 2001-07-08 16:42 jason@netspade.com
0 siblings, 1 reply; 12+ messages in thread
From: jason@netspade.com @ 2001-07-08 16:42 UTC (permalink / raw)
To: pgsql-jdbc
[[[ Original Message from Peter Eisentraut <peter_e@gmx.net> ]]]
> jason@netspade.com writes:
>
> > Is there a reason why getCatalogs() is not supported in the JDBC driver? First
> of all, what is the definition of a catalog? The MySQL JDBC driver simply returns
> a list of the databases so a simple select datname from pg_database; would do
> the same thing. However there is probably a reason for this and I would be grateful
> if you would explain.
>
> It is as of three minutes ago.
Thanks a lot :) How can I help with coding the JDBC classes? I have some code for getting table privileges etc. which I'd like to add. Do I need a cvs username or should I post the code here?
Thanks,
Jason Davies
jason@netspade.com
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: DatabaseMetaData.getCatalogs()
@ 2001-07-08 20:16 Bruce Momjian <pgman@candle.pha.pa.us>
parent: jason@netspade.com
0 siblings, 0 replies; 12+ messages in thread
From: Bruce Momjian @ 2001-07-08 20:16 UTC (permalink / raw)
To: jason@netspade.com; +Cc: pgsql-jdbc
> [[[ Original Message from Peter Eisentraut <peter_e@gmx.net> ]]]
>
> > jason@netspade.com writes:
> >
> > > Is there a reason why getCatalogs() is not supported in the JDBC driver? First
> > of all, what is the definition of a catalog? The MySQL JDBC driver simply returns
> > a list of the databases so a simple select datname from pg_database; would do
> > the same thing. However there is probably a reason for this and I would be grateful
> > if you would explain.
> >
> > It is as of three minutes ago.
>
> Thanks a lot :) How can I help with coding the JDBC classes? I have some code for getting table privileges etc. which I'd like to add. Do I need a cvs username or should I post the code here?
Just send over a context diff patch, either against 7.1.2 or CVS.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: DatabaseMetaData.getCatalogs()
@ 2001-07-08 21:41 jason@netspade.com
0 siblings, 3 replies; 12+ messages in thread
From: jason@netspade.com @ 2001-07-08 21:41 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>
[[[ Original Message from Bruce Momjian <pgman@candle.pha.pa.us> ]]]
>
> Just send over a context diff patch, either against 7.1.2 or CVS.
Okay here's a context diff against CVS for getting table privileges. I may have more code to add (I noticed getColumnPrivileges() is not completed - could use my routine for parsing pg_class.relacl?).
Jason Davies
jason@netspade.com
Attachments:
diff (application/octet-stream, 3.0K) download
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: DatabaseMetaData.getCatalogs()
@ 2001-07-08 21:50 Bruce Momjian <pgman@candle.pha.pa.us>
parent: jason@netspade.com
2 siblings, 0 replies; 12+ messages in thread
From: Bruce Momjian @ 2001-07-08 21:50 UTC (permalink / raw)
To: jason@netspade.com; +Cc: pgsql-jdbc
I am Cc'ing the jdbc list.
> [[[ Original Message from Bruce Momjian <pgman@candle.pha.pa.us> ]]]
>
> >
> > Just send over a context diff patch, either against 7.1.2 or CVS.
>
> Okay here's a context diff against CVS for getting table privileges. I may have more code to add (I noticed getColumnPrivileges() is not completed - could use my routine for parsing pg_class.relacl?).
>
> Jason Davies
>
> jason@netspade.com
[ Attachment, skipping... ]
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: DatabaseMetaData.getCatalogs()
@ 2001-07-09 01:34 Tom Lane <tgl@sss.pgh.pa.us>
parent: jason@netspade.com
2 siblings, 0 replies; 12+ messages in thread
From: Tom Lane @ 2001-07-09 01:34 UTC (permalink / raw)
To: jason@netspade.com; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; pgsql-jdbc
jason@netspade.com writes:
> Okay here's a context diff against CVS for getting table privileges.
This appears not to be correct for current sources --- the privilege
set has changed since 7.1.
regards, tom lane
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: DatabaseMetaData.getCatalogs()
@ 2001-07-09 09:02 jason@netspade.com
0 siblings, 0 replies; 12+ messages in thread
From: jason@netspade.com @ 2001-07-09 09:02 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-jdbc
[[[ Original Message from Tom Lane <tgl@sss.pgh.pa.us> ]]]
> jason@netspade.com writes:
> > Okay here's a context diff against CVS for getting table privileges.
>
> This appears not to be correct for current sources --- the privilege
> set has changed since 7.1.
Ah you probably know better than me. It works in 7.1 for me, but does it have to be backwards compatible? Where can I find out how the new privilege set works?
Thanks,
Jason
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: DatabaseMetaData.getCatalogs()
@ 2001-07-09 16:03 Peter Eisentraut <peter_e@gmx.net>
parent: jason@netspade.com
2 siblings, 0 replies; 12+ messages in thread
From: Peter Eisentraut @ 2001-07-09 16:03 UTC (permalink / raw)
To: jason@netspade.com; +Cc: pgsql-jdbc
jason@netspade.com writes:
> Okay here's a context diff against CVS for getting table privileges. I may have more code to add (I noticed getColumnPrivileges() is not completed - could use my routine for parsing pg_class.relacl?).
The list of columns you return is wrong. There is no COLUMN_NAME column.
TABLE_CAT should be filled in with the database name (should be available
via getConnection().getCatalog()). A missing TABLE_SCHEM should be set to
null (in the SQL sense). Also you have GRANTOR and GRANTEE mixed up,
besides the fact that PostgreSQL doesn't store the GRANTEE at all (yet).
--
Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: DatabaseMetaData.getCatalogs()
@ 2001-07-09 17:44 jason@netspade.com
0 siblings, 1 reply; 12+ messages in thread
From: jason@netspade.com @ 2001-07-09 17:44 UTC (permalink / raw)
To: pgsql-jdbc
[[[ Original Message from Peter Eisentraut <peter_e@gmx.net> ]]]
> The list of columns you return is wrong. There is no COLUMN_NAME column.
Does PostgreSQL actually support privileges for individual columns?
> TABLE_CAT should be filled in with the database name (should be available
> via getConnection().getCatalog()). A missing TABLE_SCHEM should be set to
> null (in the SQL sense). Also you have GRANTOR and GRANTEE mixed up,
> besides the fact that PostgreSQL doesn't store the GRANTEE at all (yet).
Sorry about that. Surely the grantee is the username in the relacl field e.g. {"=","jason=arwR"} and the grantor is the owner of the table?
Jason
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: DatabaseMetaData.getCatalogs()
@ 2001-07-10 14:57 Peter Eisentraut <peter_e@gmx.net>
parent: jason@netspade.com
0 siblings, 0 replies; 12+ messages in thread
From: Peter Eisentraut @ 2001-07-10 14:57 UTC (permalink / raw)
To: jason@netspade.com; +Cc: pgsql-jdbc
jason@netspade.com writes:
> > The list of columns you return is wrong. There is no COLUMN_NAME column.
>
> Does PostgreSQL actually support privileges for individual columns?
No. Even if it would, this would belong into
DatabaseMetaData.getColumnPrivileges(). getColumnPrivileges() could still
be implemented, it would just look at the table privileges instead.
> > TABLE_CAT should be filled in with the database name (should be available
> > via getConnection().getCatalog()). A missing TABLE_SCHEM should be set to
> > null (in the SQL sense). Also you have GRANTOR and GRANTEE mixed up,
> > besides the fact that PostgreSQL doesn't store the GRANTEE at all (yet).
>
> Sorry about that. Surely the grantee is the username in the relacl
> field e.g. {"=","jason=arwR"} and the grantor is the owner of the
> table?
Most likely, but it could also be any superuser. Since we don't allow
grant options anyway I would just set it to null to not confuse the issue.
--
Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter
^ permalink raw reply [nested|flat] 12+ messages in thread
* DatabaseMetaData.getCatalogs()
@ 2007-02-21 09:34 Peter Futaro <peterfutaro@gmail.com>
0 siblings, 1 reply; 12+ messages in thread
From: Peter Futaro @ 2007-02-21 09:34 UTC (permalink / raw)
To: pgsql-jdbc
Dear all,
I have a remote machine, which is ushing Postgres v.7.4.11.
This machine has 2 database :
Database A & Database B
I have a task to list out the available database inside that machine in a
combo box. I have tried to using :
public String getDBList()
{
String s = "";
try
{
Class.forName(sDriver);
connection_this = DriverManager.getConnection(sURL, sUser,
sPassword);
dbMetaData_this = connection_this.getMetaData();
resultSet_this = dbMetaData_this.getCatalogs();
while(resultSet_this.next())
{
if(!resultSet_this.isFirst())
s += ",";
s += resultSet_this.getString(1);
}
return s;
}
catch(SQLException e)
{
return "error";
}
}
This will only return the database, that I state inside the URL
(e.g. String sURL = "jdbc:postgresql://<<ip>>:5432/databaseA" ---> will
return "databaseA" only).
I try to connect without stating any database inside the URL, also cannot.
Can you guys please help me ?
Thank you.
Peter Futaro
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: DatabaseMetaData.getCatalogs()
@ 2007-02-21 15:33 Altaf Malik <mmalik_altaf@yahoo.com>
parent: Peter Futaro <peterfutaro@gmail.com>
0 siblings, 0 replies; 12+ messages in thread
From: Altaf Malik @ 2007-02-21 15:33 UTC (permalink / raw)
To: Peter Futaro <peterfutaro@gmail.com>; pgsql-jdbc
JDBC does not allow to collect an information for the database you are not conected to. The method getCatalogs does not return databases, instead it returns the catalogs in current database. To list down the available databases, you need to query the catalog tables. For example, on postgres you can use :
select datname from pg_catalog.pg_database where datname not in('template0','template1')
This will populate all the databases.
--Altaf Malik
EnterpriseDB
www.enterprisedb.com
Peter Futaro <peterfutaro@gmail.com> wrote:
Dear all,
I have a remote machine, which is ushing Postgres v.7.4.11.
This machine has 2 database :
Database A & Database B
I have a task to list out the available database inside that machine in a combo box. I have tried to using :
public String getDBList()
{
String s = "";
try
{
Class.forName(sDriver);
connection_this = DriverManager.getConnection(sURL, sUser, sPassword);
dbMetaData_this = connection_this.getMetaData();
resultSet_this = dbMetaData_this.getCatalogs();
while(resultSet_this.next())
{
if(!resultSet_this.isFirst())
s += ",";
s += resultSet_this.getString(1);
}
return s;
}
catch(SQLException e)
{
return "error";
}
}
This will only return the database, that I state inside the URL
(e.g. String sURL = "jdbc:postgresql://<<ip>>:5432/databaseA" ---> will return "databaseA" only).
I try to connect without stating any database inside the URL, also cannot.
Can you guys please help me ?
Thank you.
Peter Futaro
---------------------------------
Don't get soaked. Take a quick peak at the forecast
with theYahoo! Search weather shortcut.
^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2007-02-21 15:33 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-07-06 22:33 DatabaseMetaData.getCatalogs() jason@netspade.com
2001-07-08 16:42 Re: DatabaseMetaData.getCatalogs() jason@netspade.com
2001-07-08 20:16 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-07-08 21:41 Re: DatabaseMetaData.getCatalogs() jason@netspade.com
2001-07-08 21:50 ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-07-09 01:34 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-07-09 16:03 ` Peter Eisentraut <peter_e@gmx.net>
2001-07-09 09:02 Re: DatabaseMetaData.getCatalogs() jason@netspade.com
2001-07-09 17:44 Re: DatabaseMetaData.getCatalogs() jason@netspade.com
2001-07-10 14:57 ` Peter Eisentraut <peter_e@gmx.net>
2007-02-21 09:34 DatabaseMetaData.getCatalogs() Peter Futaro <peterfutaro@gmail.com>
2007-02-21 15:33 ` Altaf Malik <mmalik_altaf@yahoo.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox