Package org.apache.jackrabbit.core.fs.db
Class DbFileSystem
- java.lang.Object
-
- org.apache.jackrabbit.core.fs.db.DatabaseFileSystem
-
- org.apache.jackrabbit.core.fs.db.DbFileSystem
-
- All Implemented Interfaces:
FileSystem
,DatabaseAware
- Direct Known Subclasses:
DB2FileSystem
,DerbyFileSystem
,MSSqlFileSystem
,OracleFileSystem
public class DbFileSystem extends DatabaseFileSystem implements DatabaseAware
DbFileSystem
is a generic JDBC-basedFileSystem
implementation for Jackrabbit that persists file system entries in a database table.It is configured through the following properties:
driver
: the FQN name of the JDBC driver classurl
: the database url of the formjdbc:subprotocol:subname
user
: the database userpassword
: the user's passwordschema
: type of schema to be used (e.g.mysql
,mssql
, etc.);schemaObjectPrefix
: prefix to be prepended to schema objects
getClass().getResourceAsStream(schema + ".ddl")
. Every line in the specified .ddl file is executed separatly by callingjava.sql.Statement.execute(String)
where every occurence of the the string"${schemaObjectPrefix}"
has been replaced with the value of the propertyschemaObjectPrefix
.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 Ingres:<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem"> <param name="driver" value="com.ingres.jdbc.IngresDriver"/> <param name="url" value="jdbc:ingres://localhost:II7/test"/> <param name="schema" value="ingres"/> <param name="user" value="ingres"/> <param name="password" value="ingres"/> <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 alsoDerbyFileSystem
,DB2FileSystem
,OracleFileSystem
.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
dataSourceName
protected String
driver
the full qualified JDBC driver nameprotected String
password
the JDBC connection passwordprotected String
url
the JDBC connection URLprotected String
user
the JDBC connection user-
Fields inherited from class org.apache.jackrabbit.core.fs.db.DatabaseFileSystem
conHelper, copyFileSQL, copyFilesSQL, deleteFileSQL, deleteFolderSQL, INITIAL_BUFFER_SIZE, initialized, insertFileSQL, insertFolderSQL, schema, schemaObjectPrefix, selectChildCountSQL, selectDataSQL, selectExistSQL, selectFileAndFolderNamesSQL, selectFileExistSQL, selectFileNamesSQL, selectFolderExistSQL, selectFolderNamesSQL, selectLastModifiedSQL, selectLengthSQL, updateDataSQL, updateLastModifiedSQL
-
Fields inherited from interface org.apache.jackrabbit.core.fs.FileSystem
SEPARATOR, SEPARATOR_CHAR
-
-
Constructor Summary
Constructors Constructor Description DbFileSystem()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
protected DataSource
getDataSource()
String
getDataSourceName()
String
getDriver()
String
getPassword()
String
getUrl()
String
getUser()
int
hashCode()
Returns zero to satisfy the Object equals/hashCode contract.void
setConnectionFactory(ConnectionFactory connnectionFactory)
void
setDataSourceName(String dataSourceName)
void
setDriver(String driver)
void
setPassword(String password)
void
setUrl(String url)
void
setUser(String user)
-
Methods inherited from class org.apache.jackrabbit.core.fs.db.DatabaseFileSystem
buildSQLStatements, close, createCheckSchemaOperation, createConnectionHelper, createDeepFolder, createFolder, deleteFile, deleteFolder, exists, getInputStream, getOutputStream, getSchema, getSchemaObjectPrefix, hasChildren, init, isFile, isFolder, isSchemaCheckEnabled, lastModified, length, list, listFiles, listFolders, setSchema, setSchemaCheckEnabled, setSchemaObjectPrefix, verifyRootExists
-
-
-
-
Method Detail
-
setConnectionFactory
public void setConnectionFactory(ConnectionFactory connnectionFactory)
- Specified by:
setConnectionFactory
in interfaceDatabaseAware
-
getUrl
public String getUrl()
-
setUrl
public void setUrl(String url)
-
getUser
public String getUser()
-
setUser
public void setUser(String user)
-
getPassword
public String getPassword()
-
setPassword
public void setPassword(String password)
-
getDriver
public String getDriver()
-
setDriver
public void setDriver(String driver)
-
getDataSourceName
public String getDataSourceName()
-
setDataSourceName
public void setDataSourceName(String dataSourceName)
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classDatabaseFileSystem
-
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 classDatabaseFileSystem
- Returns:
- always zero
- See Also:
Object.hashCode()
-
getDataSource
protected final DataSource getDataSource() throws Exception
- Specified by:
getDataSource
in classDatabaseFileSystem
- Returns:
- Throws:
Exception
-
-