public class Database extends Object
This class looks for database SQL statements in properties files named "binary_store_{type}_database.properties
"
located within the "org/modeshape/jcr/database" area of the classpath, where "{type}
" is
determined
from the connection, and matches one of the following:
mysql
postgres
derby
hsql
h2
sqlite
db2
db2_390
informix
interbase
firebird
sqlserver
access
oracle
sybase
binary_store_default_database.properties
" file
is used.
Each property file should contain the set of DDL and DML statements that are used by the binary store, and the
database-specific file allows database-specific schemas and queries to be used. If the properties file that corresponds to the
connection's database type is not found on the classpath, then the "binary_store_default_database.properties
" file
is used.
ModeShape does not provide out-of-the-box properties files for each of the database types listed above. If you run into any problems, you can override the statements by providing a property file that matches the naming pattern described above, and by putting that file on the classpath. (If you want to override one of ModeShape's out-of-the-box properties files, then be sure to put your custom file first on the classpath.)
Modifier and Type | Class and Description |
---|---|
protected class |
Database.DatabaseBinaryStream |
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_MAX_EXTRACTED_TEXT_LENGTH |
protected static String |
DEFAULT_STATEMENTS_FILE_PATH |
static String |
STATEMENTS_FILE_PATH |
protected static String |
STATEMENTS_FILE_PREFIX |
protected static String |
STATEMENTS_FILENAME_SUFFIX |
static String |
TABLE_NAME |
Modifier | Constructor and Description |
---|---|
protected |
Database(Connection connection)
Creates new instance of the database.
|
protected |
Database(Connection connection,
String prefix)
Creates new instance of the database.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
contentExists(BinaryKey key,
boolean inUse,
Connection connection) |
protected Set<BinaryKey> |
getBinaryKeys(Connection connection) |
protected String |
getExtractedText(BinaryKey key,
Connection connection) |
protected String |
getMimeType(BinaryKey key,
Connection connection) |
protected String |
getTableName() |
protected void |
insertContent(BinaryKey key,
InputStream stream,
long size,
Connection connection) |
protected void |
markUnused(Iterable<BinaryKey> keys,
Connection connection) |
protected PreparedStatement |
prepareStatement(String statementKey,
Connection connection) |
protected InputStream |
readContent(BinaryKey key,
Connection connection)
Attempts to return the content stream for a given binary value.
|
protected void |
removeExpiredContent(long deadline,
Connection connection) |
protected void |
restoreContent(Connection connection,
Iterable<BinaryKey> keys) |
protected void |
setExtractedText(BinaryKey key,
String text,
Connection connection) |
protected void |
setMimeType(BinaryKey key,
String mimeType,
Connection connection) |
protected static void |
tryToClose(Connection connection) |
protected static void |
tryToClose(PreparedStatement statement) |
protected static void |
tryToClose(ResultSet resultSet) |
public static final String TABLE_NAME
public static final String STATEMENTS_FILE_PATH
protected static final String STATEMENTS_FILE_PREFIX
protected static final String STATEMENTS_FILENAME_SUFFIX
protected static final String DEFAULT_STATEMENTS_FILE_PATH
protected static final int DEFAULT_MAX_EXTRACTED_TEXT_LENGTH
protected Database(Connection connection) throws IOException, SQLException
connection
- a Connection
instance; may not be nullIOException
- if the statements cannot be processedSQLException
- if the db initialization sequence failsprotected Database(Connection connection, String prefix) throws IOException, SQLException
connection
- a Connection
instance; may not be nullprefix
- the prefix for the table name; may be null or blankIOException
- if the statements cannot be processedSQLException
- if the db initialization sequence failsprotected String getTableName()
protected PreparedStatement prepareStatement(String statementKey, Connection connection) throws SQLException
SQLException
protected void insertContent(BinaryKey key, InputStream stream, long size, Connection connection) throws SQLException
SQLException
protected boolean contentExists(BinaryKey key, boolean inUse, Connection connection) throws SQLException
SQLException
protected InputStream readContent(BinaryKey key, Connection connection) throws SQLException
key
- a BinaryKey
the key of the binary value, may not be nullconnection
- a Connection
instance, may not be nullnull
, meaning that the binary was not found.SQLException
- if anything unexpected failsprotected void markUnused(Iterable<BinaryKey> keys, Connection connection) throws SQLException
SQLException
protected void restoreContent(Connection connection, Iterable<BinaryKey> keys) throws SQLException
SQLException
protected void removeExpiredContent(long deadline, Connection connection) throws SQLException
SQLException
protected String getMimeType(BinaryKey key, Connection connection) throws SQLException
SQLException
protected void setMimeType(BinaryKey key, String mimeType, Connection connection) throws SQLException
SQLException
protected String getExtractedText(BinaryKey key, Connection connection) throws SQLException
SQLException
protected void setExtractedText(BinaryKey key, String text, Connection connection) throws SQLException
SQLException
protected Set<BinaryKey> getBinaryKeys(Connection connection) throws SQLException
SQLException
protected static void tryToClose(PreparedStatement statement)
protected static void tryToClose(ResultSet resultSet)
protected static void tryToClose(Connection connection)
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.