incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1215510 - in /incubator/lcf/branches/release-0.4-incubating-branch: ./ framework/core/src/main/java/org/apache/manifoldcf/core/database/
Date Sat, 17 Dec 2011 15:26:20 GMT
Author: kwright
Date: Sat Dec 17 15:26:19 2011
New Revision: 1215510

URL: http://svn.apache.org/viewvc?rev=1215510&view=rev
Log:
Pull up fix for CONNECTORS-330 from trunk.

Modified:
    incubator/lcf/branches/release-0.4-incubating-branch/   (props changed)
    incubator/lcf/branches/release-0.4-incubating-branch/CHANGES.txt
    incubator/lcf/branches/release-0.4-incubating-branch/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java
    incubator/lcf/branches/release-0.4-incubating-branch/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java

Propchange: incubator/lcf/branches/release-0.4-incubating-branch/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec 17 15:26:19 2011
@@ -14,4 +14,4 @@
 /incubator/lcf/branches/CONNECTORS-290:1204836-1205502
 /incubator/lcf/branches/CONNECTORS-313:1213173-1214848
 /incubator/lcf/branches/CONNECTORS-32:1092556-1094216
-/incubator/lcf/trunk:1214045,1214707,1214850,1214893,1215025,1215091,1215096,1215099,1215269,1215386
+/incubator/lcf/trunk:1214045,1214707,1214850,1214893,1215025,1215091,1215096,1215099,1215269,1215386,1215508

Modified: incubator/lcf/branches/release-0.4-incubating-branch/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/release-0.4-incubating-branch/CHANGES.txt?rev=1215510&r1=1215509&r2=1215510&view=diff
==============================================================================
--- incubator/lcf/branches/release-0.4-incubating-branch/CHANGES.txt (original)
+++ incubator/lcf/branches/release-0.4-incubating-branch/CHANGES.txt Sat Dec 17 15:26:19 2011
@@ -3,6 +3,13 @@ $Id$
 
 ======================= 0.4-dev =====================
 
+CONNECTORS-330: Add infrastructure that permits the database class
+to initialize a connection every time it is pulled from the pool.  This is
+necessary to support HSQLDB, because a number of HSQLDB's states
+are actually maintained in the JDBC driver and thus cannot be managed
+well in a pooled connection paradigm.
+(Fred Toussi, Karl Wright)
+
 CONNECTORS-321: Correct a problem with external HSQLDB databases
 where the schema wasn't being reliably set for the session.
 (Fred Toussi, Karl Wright)

Modified: incubator/lcf/branches/release-0.4-incubating-branch/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/release-0.4-incubating-branch/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java?rev=1215510&r1=1215509&r2=1215510&view=diff
==============================================================================
--- incubator/lcf/branches/release-0.4-incubating-branch/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java
(original)
+++ incubator/lcf/branches/release-0.4-incubating-branch/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java
Sat Dec 17 15:26:19 2011
@@ -114,6 +114,20 @@ public class DBInterfaceHSQLDB extends D
     return pathString + databaseName;
   }
 
+  /** Initialize the connection (for HSQLDB).
+  * HSQLDB has a great deal of session state, and no way to pool individual connections based
on it.
+  * So, every time we pull a connection off the pool we have to execute a number of statements
on it
+  * before it can work reliably for us.  This is the abstraction that permits that to happen.
+  *@param connection is the JDBC connection.
+  */
+  protected void initializeConnection(Connection connection)
+    throws ManifoldCFException
+  {
+    super.initializeConnection(connection);
+    // Set the schema
+    executeViaThread(connection,"SET SCHEMA "+schemaNameForQueries.toUpperCase(),null,false,-1,null,null);
+  }
+
   /** Initialize.  This method is called once per JVM instance, in order to set up
   * database communication.
   */
@@ -578,7 +592,7 @@ public class DBInterfaceHSQLDB extends D
     if (isRemote)
     {
       // Create a connection using the admin credentials
-      Database masterDatabase = new DBInterfaceHSQLDB(context,"administration",adminUserName,adminPassword);
+      Database masterDatabase = new DBInterfaceHSQLDB(context,"PUBLIC",adminUserName,adminPassword);
       ArrayList params = new ArrayList();
       // First, look for user
       params.add(userName);
@@ -599,10 +613,8 @@ public class DBInterfaceHSQLDB extends D
       if (schemaResult.getRowCount() == 0)
       {
         // Create the schema
-	masterDatabase.executeQuery("CREATE SCHEMA "+databaseName+" AUTHORIZATION "+quoteString(userName),null,
+	masterDatabase.executeQuery("CREATE SCHEMA "+databaseName.toUpperCase()+" AUTHORIZATION
"+quoteString(userName),null,
           null,invalidateKeys,null,false,0,null,null);
-	masterDatabase.executeQuery("ALTER USER "+quoteString(userName)+" SET INITIAL SCHEMA "+databaseName,null,
-	  null,invalidateKeys,null,false,0,null,null);
       }
     }
     else
@@ -637,13 +649,13 @@ public class DBInterfaceHSQLDB extends D
     if (isRemote)
     {
       // Drop the schema, then the user
-      Database masterDatabase = new DBInterfaceHSQLDB(context,"administration",adminUserName,adminPassword);
+      Database masterDatabase = new DBInterfaceHSQLDB(context,"PUBLIC",adminUserName,adminPassword);
       try
       {
         // Drop schema
         masterDatabase.executeQuery("DROP SCHEMA "+databaseName,null,null,invalidateKeys,null,false,0,null,null);
         // Drop user
-        masterDatabase.executeQuery("DROP USER "+userName,null,null,invalidateKeys,null,false,0,null,null);
+        masterDatabase.executeQuery("DROP USER "+quoteString(userName),null,null,invalidateKeys,null,false,0,null,null);
       }
       catch (ManifoldCFException e)
       {

Modified: incubator/lcf/branches/release-0.4-incubating-branch/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/release-0.4-incubating-branch/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java?rev=1215510&r1=1215509&r2=1215510&view=diff
==============================================================================
--- incubator/lcf/branches/release-0.4-incubating-branch/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
(original)
+++ incubator/lcf/branches/release-0.4-incubating-branch/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
Sat Dec 17 15:26:19 2011
@@ -243,6 +243,8 @@ public abstract class Database
       connection = ConnectionFactory.getConnection(jdbcUrl,jdbcDriverClass,databaseName,userName,password);
       try
       {
+        // Initialize the connection (for HSQLDB)
+        initializeConnection(connection);
         // Start a transaction
         startATransaction();
       }
@@ -713,6 +715,8 @@ public abstract class Database
       Connection tempConnection = ConnectionFactory.getConnection(jdbcUrl,jdbcDriverClass,databaseName,userName,password);
       try
       {
+        // Initialize the connection (for HSQLDB)
+        initializeConnection(tempConnection);
         return executeViaThread(tempConnection,query,params,bResults,maxResults,spec,returnLimit);
       }
       catch (ManifoldCFException e)
@@ -733,6 +737,18 @@ public abstract class Database
 
   // These are protected helper methods
 
+  /** Initialize the connection (for HSQLDB).
+  * HSQLDB has a great deal of session state, and no way to pool individual connections based
on it.
+  * So, every time we pull a connection off the pool we have to execute a number of statements
on it
+  * before it can work reliably for us.  This is the abstraction that permits that to happen.
+  *@param connection is the JDBC connection.
+  */
+  protected void initializeConnection(Connection connection)
+    throws ManifoldCFException
+  {
+    // Default implementation does nothing; override to make special stuff happen.
+  }
+  
   /** Run a query.  No caching is involved at all at this level.
   * @param query String the query string
   * @param bResults boolean whether to load the resultset or not



Mime
View raw message