summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/interfaces/jdbc/org/postgresql/Connection.java32
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/Connection.java26
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java26
3 files changed, 33 insertions, 51 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/Connection.java b/src/interfaces/jdbc/org/postgresql/Connection.java
index d62127e7c32..7d80f4c4ba8 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
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/Connection.java b/src/interfaces/jdbc/org/postgresql/jdbc1/Connection.java
index 188448925e6..91d38a8de15 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/Connection.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc1/Connection.java
@@ -17,7 +17,7 @@ import org.postgresql.largeobject.*;
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.5 2001/01/18 17:37:13 peter Exp $
+ * $Id: Connection.java,v 1.6 2001/07/21 18:56:17 momjian Exp $
*
* A Connection represents a session with a specific database. Within the
* context of a Connection, SQL statements are executed and results are
@@ -273,30 +273,6 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
}
/**
- * 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
- {
- // No-op
- }
-
- /**
- * 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 null;
- }
-
- /**
* You can call this method to try to change the transaction
* isolation level using one of the TRANSACTION_* values.
*
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java b/src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java
index 7e01943da4a..cef4cbf0019 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java
@@ -17,7 +17,7 @@ import org.postgresql.largeobject.*;
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.7 2001/02/13 16:39:02 peter Exp $
+ * $Id: Connection.java,v 1.8 2001/07/21 18:56:17 momjian Exp $
*
* A Connection represents a session with a specific database. Within the
* context of a Connection, SQL statements are executed and results are
@@ -356,30 +356,6 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
}
/**
- * 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
- {
- // No-op
- }
-
- /**
- * 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 null;
- }
-
- /**
* You can call this method to try to change the transaction
* isolation level using one of the TRANSACTION_* values.
*