diff options
author | Bruce Momjian <bruce@momjian.us> | 2001-07-21 18:56:17 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2001-07-21 18:56:17 +0000 |
commit | eec08cddb457a7f9c14a9d52a50fc6ff7f8f5e58 (patch) | |
tree | 15c361ee8c2e17e0cff896bbd647ed7e7be72d3b /src/interfaces/jdbc/org/postgresql/Connection.java | |
parent | ff21a8e5c86457e205ff7c598b930efd711cb2dc (diff) | |
download | postgresql-eec08cddb457a7f9c14a9d52a50fc6ff7f8f5e58.tar.gz |
Great, here is a context diff of CVS for implementing the get/setCatalog methods
in Connection - note: I've updated setCatalog(String catalog) from my previous
diff so it checks whether it is already connected to the specified catalog.
Jason Davies
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/Connection.java')
-rw-r--r-- | src/interfaces/jdbc/org/postgresql/Connection.java | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/Connection.java b/src/interfaces/jdbc/org/postgresql/Connection.java index d62127e7c3..7d80f4c4ba 100644 --- a/src/interfaces/jdbc/org/postgresql/Connection.java +++ b/src/interfaces/jdbc/org/postgresql/Connection.java @@ -11,7 +11,7 @@ import org.postgresql.util.*; import org.postgresql.core.Encoding; /** - * $Id: Connection.java,v 1.19 2001/07/21 18:52:10 momjian Exp $ + * $Id: Connection.java,v 1.20 2001/07/21 18:56:17 momjian Exp $ * * This abstract class is used by org.postgresql.Driver to open either the JDBC1 or * JDBC2 versions of the Connection class. @@ -791,6 +791,36 @@ public abstract class Connection public abstract void close() throws SQLException; /** + * A sub-space of this Connection's database may be selected by + * setting a catalog name. If the driver does not support catalogs, + * it will silently ignore this request + * + * @exception SQLException if a database access error occurs + */ + public void setCatalog(String catalog) throws SQLException + { + if(catalog!=null && !catalog.equals(PG_DATABASE)) { + close(); + Properties info=new Properties(); + info.setProperty("user", PG_USER); + info.setProperty("password", PG_PASSWORD); + openConnection(PG_HOST, PG_PORT, info, catalog, this_url, this_driver); + } + } + + /** + * Return the connections current catalog name, or null if no + * catalog name is set, or we dont support catalogs. + * + * @return the current catalog name or null + * @exception SQLException if a database access error occurs + */ + public String getCatalog() throws SQLException + { + return PG_DATABASE; + } + + /** * Overides finalize(). If called, it closes the connection. * * This was done at the request of Rachel Greenham |