Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java	(revision 888792)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java	(working copy)
@@ -464,9 +464,13 @@
                 throw new RepositoryException(msg);
             }
             BufferedReader reader = new BufferedReader(new InputStreamReader(in));
-            Statement stmt = connectionManager.getConnection().createStatement();
+            Connection connection = connectionManager.getConnection();
+            Statement stmt = null;
             String sql = null;
+            boolean success = false;
             try {
+                connection.setAutoCommit(false);
+                stmt = connection.createStatement();
                 sql = reader.readLine();
                 while (sql != null) {
                     if (!sql.startsWith("#") && sql.length() > 0
@@ -479,6 +483,7 @@
                     // read next sql stmt
                     sql = reader.readLine();
                 }
+                success = true;
             } catch (IOException e) {
                 String msg = "Configuration error: unable to read the resource '" + databaseType + ".ddl': " + e;
                 log.debug(msg);
@@ -490,7 +495,35 @@
                 throw se;
             } finally {
                 IOUtils.closeQuietly(in);
+                endTransaction(connection, stmt, success);
+            }
+        }
+    }
+
+    /**
+     * Ends a JDBC transaction and closes the given statement.
+     * 
+     * @param connection the connection to commit or rollback
+     * @param stmt the statement to close
+     * @param commit whether to commit or rollback
+     * @throws SQLException if the commit failed (not if the rollback failed!)
+     */
+    private void endTransaction(Connection connection, Statement stmt, boolean commit) throws SQLException {
+        try {
+            if (commit) {
+                connection.commit();
+            } else {
+                try {
+                    connection.rollback();
+                } catch (SQLException e) {
+                    log.error("Failed to properly rollback schema creation ", e);
+                }
+            }
+        } finally {
+            try {
                 stmt.close();
+            } catch (SQLException e) {
+                log.error("Failed to properly close statement ", e);
             }
         }
     }
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/CheckSchemaOperation.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/CheckSchemaOperation.java	(revision 888792)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/CheckSchemaOperation.java	(working copy)
@@ -26,6 +26,8 @@
 
 import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.util.Text;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * An operation which synchronously checks the DB schema in the {@link #run()} method. The
@@ -33,6 +35,8 @@
  */
 public class CheckSchemaOperation {
 
+    private static Logger log = LoggerFactory.getLogger(CheckSchemaOperation.class);
+
     public static final String SCHEMA_OBJECT_PREFIX_VARIABLE = "${schemaObjectPrefix}";
 
     public static final String TABLE_SPACE_VARIABLE = "${tableSpace}";
@@ -71,6 +75,8 @@
 
     /**
      * Checks if the required schema objects exist and creates them if they don't exist yet.
+     * The creation of database objects is wrapped in a JDBC transaction to prevent partially created
+     * schemas (JCR-936).
      * 
      * @throws SQLException if an error occurs
      * @throws IOException if an error occurs
@@ -78,6 +84,8 @@
     public void run() throws SQLException, IOException {
         if (!conHelper.tableExists(table)) {
             BufferedReader reader = new BufferedReader(new InputStreamReader(ddl));
+            conHelper.startBatch();
+            boolean success = false;
             try {
                 String sql = reader.readLine();
                 while (sql != null) {
@@ -91,8 +99,20 @@
                     // read next sql stmt
                     sql = reader.readLine();
                 }
+                success = true;
             } finally {
                 IOUtils.closeQuietly(ddl);
+                try {
+                    conHelper.endBatch(success);
+                } catch (SQLException e) {
+                    if (success) {
+                        // transaction commit failed
+                        throw e;
+                    } else {
+                        // Don't mask an exception from the try block above
+                        log.warn("Failed to properly rollback the schema-creation transaction", e);
+                    }
+                }
             }
         }
     }
