|
ModeShape Distribution 3.5.0.Final | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.jcr.value.binary.Database
public class Database
Helper class for manipulation with database.
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.)
Nested Class Summary | |
---|---|
static class |
Database.Type
|
Field Summary | |
---|---|
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
|
Constructor Summary | |
---|---|
Database(Connection connection)
Creates new instance of the database. |
|
Database(Connection connection,
Database.Type type,
String prefix)
Creates new instance of the database. |
Method Summary | |
---|---|
static InputStream |
asStream(ResultSet rs)
Provides access to query data |
static String |
asString(ResultSet rs)
Provides access to query data |
static List<String> |
asStringList(ResultSet rs)
Provides access to query data |
protected Database.Type |
determineType()
|
void |
disconnect()
Closes connection with database. |
static void |
execute(PreparedStatement sql)
Executes specifies statement. |
static ResultSet |
executeQuery(PreparedStatement sql)
Runs SQL statement |
static void |
executeUpdate(PreparedStatement sql)
Executes specifies update statement. |
Connection |
getConnection()
The connection that this object is using. |
Database.Type |
getDatabaseType()
Shows type of this database. |
void |
initialize()
Prepare this instance and the underlying database for usage. |
PreparedStatement |
insertContentSQL(BinaryKey key,
InputStream stream)
Create statement for store content. |
PreparedStatement |
markUnusedSQL(BinaryKey key)
Generates SQL statement which marks content as not used. |
protected PreparedStatement |
prepareStatement(String statementKey)
|
PreparedStatement |
removeExpiredContentSQL(long deadline)
Generates SQL statement which removes expired content. |
PreparedStatement |
restoreContentSQL(BinaryKey key)
Generates SQL statement which marks content as used. |
PreparedStatement |
retrieveBinaryKeys(Set<BinaryKey> keys)
Generates SQL statement for retrieving the binary keys in the store. |
PreparedStatement |
retrieveContentSQL(BinaryKey key,
boolean inUse)
Generates SQL statement for content retrieve. |
PreparedStatement |
retrieveExtTextSQL(BinaryKey key)
Generate SQL statement which returns extracted text. |
PreparedStatement |
retrieveMimeTypeSQL(BinaryKey key)
Generates SQL statement for mime type retrieve. |
PreparedStatement |
updateExtTextSQL(BinaryKey key,
String text)
Generates SQL statement which updates extracted text field. |
PreparedStatement |
updateMimeTypeSQL(BinaryKey key,
String mimeType)
Generates SQL statement which modifies mime type value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
public Database(Connection connection) throws BinaryStoreException
connection
- connection to a database
BinaryStoreException
- if the database type cannot be determinedpublic Database(Connection connection, Database.Type type, String prefix) throws BinaryStoreException
connection
- connection to a databasetype
- the type of database; may be null if the type is to be determinedprefix
- the prefix for the table name; may be null or blank
BinaryStoreException
- if the database type cannot be determinedMethod Detail |
---|
public void initialize() throws BinaryStoreException
BinaryStoreException
- if there is a problemprotected PreparedStatement prepareStatement(String statementKey) throws SQLException
SQLException
protected Database.Type determineType() throws BinaryStoreException
BinaryStoreException
public void disconnect()
public Connection getConnection()
public Database.Type getDatabaseType()
public PreparedStatement insertContentSQL(BinaryKey key, InputStream stream) throws BinaryStoreException
key
- unique content identifierstream
- content to store
BinaryStoreException
public PreparedStatement retrieveContentSQL(BinaryKey key, boolean inUse) throws BinaryStoreException
key
- content idinUse
- true if the binary given by the key is expected to be still be in use, or false if the binary can be no longer
used
BinaryStoreException
public PreparedStatement markUnusedSQL(BinaryKey key) throws BinaryStoreException
key
- the content id.
BinaryStoreException
public PreparedStatement restoreContentSQL(BinaryKey key) throws BinaryStoreException
key
- the content id.
BinaryStoreException
public PreparedStatement removeExpiredContentSQL(long deadline) throws BinaryStoreException
deadline
- expire time
BinaryStoreException
public PreparedStatement retrieveMimeTypeSQL(BinaryKey key) throws BinaryStoreException
key
- content id
BinaryStoreException
public PreparedStatement updateMimeTypeSQL(BinaryKey key, String mimeType) throws BinaryStoreException
key
- content idmimeType
- the new value for mime type
BinaryStoreException
public PreparedStatement retrieveExtTextSQL(BinaryKey key) throws BinaryStoreException
key
- content id
BinaryStoreException
public PreparedStatement updateExtTextSQL(BinaryKey key, String text) throws BinaryStoreException
key
- content idtext
- new value for the extracted text
BinaryStoreException
public PreparedStatement retrieveBinaryKeys(Set<BinaryKey> keys) throws BinaryStoreException
keys
- the container into which the keys should be placed
BinaryStoreException
public static void execute(PreparedStatement sql) throws BinaryStoreException
sql
- the statement to execute
BinaryStoreException
public static ResultSet executeQuery(PreparedStatement sql) throws BinaryStoreException
sql
- SQL statement
BinaryStoreException
public static void executeUpdate(PreparedStatement sql) throws BinaryStoreException
sql
- the statement to execute
BinaryStoreException
public static InputStream asStream(ResultSet rs) throws BinaryStoreException
rs
- retrieved single value
BinaryStoreException
public static String asString(ResultSet rs) throws BinaryStoreException
rs
- retrieved query result
BinaryStoreException
public static List<String> asStringList(ResultSet rs) throws BinaryStoreException
rs
- retrieved query result
BinaryStoreException
|
ModeShape Distribution 3.5.0.Final | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |