--- pgjdbc/doc/pgjdbc.xml Sun Apr 13 09:03:49 2008
+++ pgjdbc_searchpath/doc/pgjdbc.xml Tue Jul 8 11:13:02 2008
@@ -525,6 +525,18 @@
+ searchpath = String
+
+
+ Set a custom search path for this connection. The first schema in the path will be
+ used for any tables or other named objects that are created when no target schema
+ is specified in a command. This is only useful in the situation where it cannot be
+ handled by the per user or per database defaults.
+
+
+
+
+
allowEncodingChanges = boolean
--- pgjdbc/org/postgresql/Driver.java.in Sun Apr 13 09:03:49 2008
+++ pgjdbc_searchpath/org/postgresql/Driver.java.in Tue Jul 8 10:00:56 2008
@@ -180,6 +180,8 @@
* server then the character set of the database is used as the default,
* otherwise the jvm character encoding is used as the default.
* This value is only used when connecting to a 7.2 or older server.
+ * searchpath - (optional) Set a custom search path. Useful if you want to
+ * query a non-default schema but don't wish to modify your queries.
* loglevel - (optional) Enable logging of messages from the driver.
* The value is an integer from 1 to 2 where:
* INFO = 1, DEBUG = 2
@@ -447,6 +449,8 @@
{ "stringtype", Boolean.FALSE,
"The type to bind String parameters as (usually 'varchar'; 'unspecified' allows implicit casting to other types)",
new String[] { "varchar", "unspecified" } },
+ { "searchpath", Boolean.FALSE,
+ "Set a custom search path." },
};
/**
--- pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java Mon Apr 14 21:23:57 2008
+++ pgjdbc_searchpath/org/postgresql/jdbc2/AbstractJdbc2Connection.java Tue Jul 8 13:13:40 2008
@@ -160,6 +160,13 @@
_typeCache = createTypeInfo(this);
initObjectTypes(info);
+ // Set Custom Search Path
+ String searchpath = info.getProperty("searchpath");
+ if((searchpath != null) && (!(searchpath.trim().isEmpty()))){
+ String set_cmd = "SET search_path TO " + searchpath + "; show search_path";
+ execSQLQuery(set_cmd);
+ }
+
if (Boolean.valueOf(info.getProperty("logUnclosedConnections")).booleanValue()) {
openStackTrace = new Throwable("Connection was created at this point:");
enableDriverManagerLogging();