Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit eec08cd

Browse files
committed
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
1 parent ff21a8e commit eec08cd

File tree

3 files changed

+33
-51
lines changed

3 files changed

+33
-51
lines changed

src/interfaces/jdbc/org/postgresql/Connection.java

+31-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.postgresql.core.Encoding;
1212

1313
/**
14-
* $Id: Connection.java,v 1.19 2001/07/21 18:52:10 momjian Exp $
14+
* $Id: Connection.java,v 1.20 2001/07/21 18:56:17 momjian Exp $
1515
*
1616
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
1717
* JDBC2 versions of the Connection class.
@@ -790,6 +790,36 @@ private void initObjectTypes()
790790

791791
public abstract void close() throws SQLException;
792792

793+
/**
794+
* A sub-space of this Connection's database may be selected by
795+
* setting a catalog name. If the driver does not support catalogs,
796+
* it will silently ignore this request
797+
*
798+
* @exception SQLException if a database access error occurs
799+
*/
800+
public void setCatalog(String catalog) throws SQLException
801+
{
802+
if(catalog!=null && !catalog.equals(PG_DATABASE)) {
803+
close();
804+
Properties info=new Properties();
805+
info.setProperty("user", PG_USER);
806+
info.setProperty("password", PG_PASSWORD);
807+
openConnection(PG_HOST, PG_PORT, info, catalog, this_url, this_driver);
808+
}
809+
}
810+
811+
/**
812+
* Return the connections current catalog name, or null if no
813+
* catalog name is set, or we dont support catalogs.
814+
*
815+
* @return the current catalog name or null
816+
* @exception SQLException if a database access error occurs
817+
*/
818+
public String getCatalog() throws SQLException
819+
{
820+
return PG_DATABASE;
821+
}
822+
793823
/**
794824
* Overides finalize(). If called, it closes the connection.
795825
*

src/interfaces/jdbc/org/postgresql/jdbc1/Connection.java

+1-25
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.postgresql.util.*;
1818

1919
/**
20-
* $Id: Connection.java,v 1.5 2001/01/18 17:37:13 peter Exp $
20+
* $Id: Connection.java,v 1.6 2001/07/21 18:56:17 momjian Exp $
2121
*
2222
* A Connection represents a session with a specific database. Within the
2323
* context of a Connection, SQL statements are executed and results are
@@ -272,30 +272,6 @@ public boolean isReadOnly() throws SQLException
272272
return readOnly;
273273
}
274274

275-
/**
276-
* A sub-space of this Connection's database may be selected by
277-
* setting a catalog name. If the driver does not support catalogs,
278-
* it will silently ignore this request
279-
*
280-
* @exception SQLException if a database access error occurs
281-
*/
282-
public void setCatalog(String catalog) throws SQLException
283-
{
284-
// No-op
285-
}
286-
287-
/**
288-
* Return the connections current catalog name, or null if no
289-
* catalog name is set, or we dont support catalogs.
290-
*
291-
* @return the current catalog name or null
292-
* @exception SQLException if a database access error occurs
293-
*/
294-
public String getCatalog() throws SQLException
295-
{
296-
return null;
297-
}
298-
299275
/**
300276
* You can call this method to try to change the transaction
301277
* isolation level using one of the TRANSACTION_* values.

src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java

+1-25
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.postgresql.util.*;
1818

1919
/**
20-
* $Id: Connection.java,v 1.7 2001/02/13 16:39:02 peter Exp $
20+
* $Id: Connection.java,v 1.8 2001/07/21 18:56:17 momjian Exp $
2121
*
2222
* A Connection represents a session with a specific database. Within the
2323
* context of a Connection, SQL statements are executed and results are
@@ -355,30 +355,6 @@ public boolean isReadOnly() throws SQLException
355355
return readOnly;
356356
}
357357

358-
/**
359-
* A sub-space of this Connection's database may be selected by
360-
* setting a catalog name. If the driver does not support catalogs,
361-
* it will silently ignore this request
362-
*
363-
* @exception SQLException if a database access error occurs
364-
*/
365-
public void setCatalog(String catalog) throws SQLException
366-
{
367-
// No-op
368-
}
369-
370-
/**
371-
* Return the connections current catalog name, or null if no
372-
* catalog name is set, or we dont support catalogs.
373-
*
374-
* @return the current catalog name or null
375-
* @exception SQLException if a database access error occurs
376-
*/
377-
public String getCatalog() throws SQLException
378-
{
379-
return null;
380-
}
381-
382358
/**
383359
* You can call this method to try to change the transaction
384360
* isolation level using one of the TRANSACTION_* values.

0 commit comments

Comments
 (0)