Index: src/main/java/com/xpn/xwiki/store/XWikiHibernateBaseStore.java =================================================================== --- src/main/java/com/xpn/xwiki/store/XWikiHibernateBaseStore.java (révision 4882) +++ src/main/java/com/xpn/xwiki/store/XWikiHibernateBaseStore.java (copie de travail) @@ -294,7 +294,7 @@ connection = session.connection(); setDatabase(session, context); isOracle = "Oracle".equals(connection.getMetaData().getDatabaseProductName()); - + if (isOracle) { dschema = config.getProperty(Environment.DEFAULT_SCHEMA); config.setProperty(Environment.DEFAULT_SCHEMA, context.getDatabase()); @@ -439,7 +439,9 @@ try { if ( log.isDebugEnabled() ) log.debug("Switch database to: " + database); if (database!=null) { - if ("Oracle".equals(getDatabaseProductName(context))) { + + String dbproduct = getDatabaseProductName(context); + if ("Oracle".equals(dbproduct)) { Statement stmt = null; try { stmt = session.connection().createStatement(); @@ -450,8 +452,33 @@ stmt.close(); } catch (Exception e) {} } - - } else { + } else if ("Apache Derby".equals(dbproduct)) { + Statement stmt = null; + try { + stmt = session.connection().createStatement(); + // use default Derby database ("APP") instead of "xwiki" (considering "xwiki" is main wiki) + stmt.execute("SET SCHEMA " + (database.toLowerCase().equals("xwiki") ? "APP" : database)); + } finally { + try { + if (stmt != null) + stmt.close(); + } catch (Exception e) { + } + } + } else if ("HSQL Database Engine".equals(dbproduct)) { + Statement stmt = null; + try { + stmt = session.connection().createStatement(); + // use default HSQL database ("PUBLIC") instead of "xwiki" (considering "xwiki" is main wiki) + stmt.execute("SET SCHEMA " + (database.toLowerCase().equals("xwiki") ? "PUBLIC" : database)); + } finally { + try { + if (stmt != null) + stmt.close(); + } catch (Exception e) { + } + } + } else { String catalog = session.connection().getCatalog(); catalog = (catalog==null) ? null : catalog.replace('_', '-'); if (!database.equals(catalog)) Index: src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java =================================================================== --- src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java (révision 4882) +++ src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java (copie de travail) @@ -107,7 +107,7 @@ * @throws XWikiException */ public void createWiki(String wikiName, XWikiContext context) throws XWikiException { - boolean bTransaction = true; + boolean bTransaction = true; String database = context.getDatabase(); Statement stmt = null; try { @@ -120,6 +120,10 @@ if ("Oracle".equals(dbproduct)) { stmt.execute("create user " + wikiName + " identified by " + wikiName); stmt.execute("grant resource to " + wikiName); + } else if ("Apache Derby".equals(dbproduct)) { + stmt.execute("CREATE SCHEMA " + wikiName.replace('-', '_')); + } else if ("HSQL Database Engine".equals(dbproduct)) { + stmt.execute("CREATE SCHEMA " + wikiName.replace('-', '_') + " AUTHORIZATION DBA"); } else { stmt.execute("create database " + wikiName.replace('-','_')); }