org.apache.jackrabbit.core.fs.db
Class DbFileSystem

java.lang.Object
  extended by org.apache.jackrabbit.core.fs.db.DatabaseFileSystem
      extended by org.apache.jackrabbit.core.fs.db.DbFileSystem
All Implemented Interfaces:
FileSystem
Direct Known Subclasses:
DB2FileSystem, DerbyFileSystem, OracleFileSystem

public class DbFileSystem
extends DatabaseFileSystem

DbFileSystem is a generic JDBC-based FileSystem implementation for Jackrabbit that persists file system entries in a database table.

It is configured through the following properties:

The required schema objects are automatically created by executing the DDL statements read from the [schema].ddl file. The .ddl file is read from the resources by calling getClass().getResourceAsStream(schema + ".ddl"). Every line in the specified .ddl file is executed separatly by calling java.sql.Statement.execute(String) where every occurence of the the string "${schemaObjectPrefix}" has been replaced with the value of the property schemaObjectPrefix.

The following is a fragment from a sample configuration using MySQL:

   <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
       <param name="driver" value="com.mysql.jdbc.Driver"/>
       <param name="url" value="jdbc:mysql:///test?autoReconnect=true"/>
       <param name="schema" value="mysql"/>
       <param name="schemaObjectPrefix" value="rep_"/>
   </FileSystem>
 
The following is a fragment from a sample configuration using Daffodil One$DB Embedded:
   <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
       <param name="driver" value="in.co.daffodil.db.jdbc.DaffodilDBDriver"/>
       <param name="url" value="jdbc:daffodilDB_embedded:rep;path=${rep.home}/databases;create=true"/>
       <param name="user" value="daffodil"/>
       <param name="password" value="daffodil"/>
       <param name="schema" value="daffodil"/>
       <param name="schemaObjectPrefix" value="rep_"/>
   </FileSystem>
 
The following is a fragment from a sample configuration using MSSQL:
   <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
       <param name="driver" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
       <param name="url" value="jdbc:microsoft:sqlserver://localhost:1433;;DatabaseName=test;SelectMethod=Cursor;"/>
       <param name="schema" value="mssql"/>
       <param name="user" value="sa"/>
       <param name="password" value=""/>
       <param name="schemaObjectPrefix" value="rep_"/>
   </FileSystem>
 
The following is a fragment from a sample configuration using PostgreSQL:
   <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
       <param name="driver" value="org.postgresql.Driver"/>
       <param name="url" value="jdbc:postgresql://localhost/test"/>
       <param name="schema" value="postgresql"/>
       <param name="user" value="postgres"/>
       <param name="password" value="postgres"/>
       <param name="schemaObjectPrefix" value="rep_"/>
   </FileSystem>
 
JNDI can be used to get the connection. In this case, use the javax.naming.InitialContext as the driver, and the JNDI name as the URL. If the user and password are configured in the JNDI resource, they should not be configured here. Example JNDI settings:
 <param name="driver" value="javax.naming.InitialContext" />
 <param name="url" value="java:comp/env/jdbc/Test" />
 
See also DerbyFileSystem, DB2FileSystem, OracleFileSystem.


Field Summary
protected  java.lang.String driver
          the full qualified JDBC driver name
protected  java.lang.String password
          the JDBC connection password
protected  java.lang.String url
          the JDBC connection URL
protected  java.lang.String user
          the JDBC connection user
 
Fields inherited from class org.apache.jackrabbit.core.fs.db.DatabaseFileSystem
con, copyFileSQL, copyFilesSQL, deleteFileSQL, deleteFolderSQL, INITIAL_BUFFER_SIZE, initialized, insertFileSQL, insertFolderSQL, schema, SCHEMA_OBJECT_PREFIX_VARIABLE, schemaObjectPrefix, selectChildCountSQL, selectDataSQL, selectExistSQL, selectFileAndFolderNamesSQL, selectFileExistSQL, selectFileNamesSQL, selectFolderExistSQL, selectFolderNamesSQL, selectLastModifiedSQL, selectLengthSQL, SLEEP_BEFORE_RECONNECT, updateDataSQL, updateLastModifiedSQL
 
Fields inherited from interface org.apache.jackrabbit.core.fs.FileSystem
SEPARATOR, SEPARATOR_CHAR
 
Constructor Summary
DbFileSystem()
           
 
Method Summary
 boolean equals(java.lang.Object obj)
          
protected  java.sql.Connection getConnection()
          Initialize the JDBC connection.
 java.lang.String getDriver()
           
 java.lang.String getPassword()
           
 java.lang.String getUrl()
           
 java.lang.String getUser()
           
 int hashCode()
          Returns zero to satisfy the Object equals/hashCode contract.
 void setDriver(java.lang.String driver)
           
 void setPassword(java.lang.String password)
           
 void setUrl(java.lang.String url)
           
 void setUser(java.lang.String user)
           
 
Methods inherited from class org.apache.jackrabbit.core.fs.db.DatabaseFileSystem
buildSQLStatements, checkSchema, close, closeConnection, closeResultSet, closeStatement, copy, copyDeepFolder, copyFile, createDeepFolder, createFolder, deleteFile, deleteFolder, executeStmt, exists, getInputStream, getOutputStream, getRandomAccessOutputStream, getSchema, getSchemaObjectPrefix, hasChildren, init, initConnection, initPreparedStatements, isFile, isFolder, lastModified, length, list, listFiles, listFolders, move, prepareSchemaObjectPrefix, reestablishConnection, resetStatement, setSchema, setSchemaObjectPrefix, touch, verifyRootExists
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

driver

protected java.lang.String driver
the full qualified JDBC driver name


url

protected java.lang.String url
the JDBC connection URL


user

protected java.lang.String user
the JDBC connection user


password

protected java.lang.String password
the JDBC connection password

Constructor Detail

DbFileSystem

public DbFileSystem()
Method Detail

getUrl

public java.lang.String getUrl()

setUrl

public void setUrl(java.lang.String url)

getUser

public java.lang.String getUser()

setUser

public void setUser(java.lang.String user)

getPassword

public java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password)

getDriver

public java.lang.String getDriver()

setDriver

public void setDriver(java.lang.String driver)

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class DatabaseFileSystem

hashCode

public int hashCode()
Returns zero to satisfy the Object equals/hashCode contract. This class is mutable and not meant to be used as a hash key.

Overrides:
hashCode in class DatabaseFileSystem
Returns:
always zero
See Also:
Object.hashCode()

getConnection

protected java.sql.Connection getConnection()
                                     throws javax.jcr.RepositoryException,
                                            java.sql.SQLException
Initialize the JDBC connection.

Overrides:
getConnection in class DatabaseFileSystem
Returns:
new connection
Throws:
java.sql.SQLException - if an error occurs
javax.jcr.RepositoryException


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.