📄 ojb-repository.dtd
字号:
<!--
#/* Copyright 2004-2005 Apache Software Foundation
# *
# * Licensed under the Apache License, Version 2.0 (the "License");
# * you may not use this file except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# */
-->
<!--
Apache OJB - ObJectRelationalBridge
Bridging Java objects and relational dabatases
This DTD describes the grammar of the Descriptor repository
Initial author: Thomas Mahler
-->
<!--
The descriptor-repository is the root element of a
repository.xml file.
It consists of one jdbc-connection-descriptor and at least one
class-descriptor element.
The attribute element allows to add custom attributes.
The jdbc-connection-descriptor element specifies the default jdbc
connection for the repository.
class-descriptor elements specify o/r mapping information for
persistent classes.
-->
<!ELEMENT descriptor-repository (documentation?, attribute*,
jdbc-connection-descriptor*, class-descriptor*)>
<!--
The version attribute is used to bind a repository.xml
file to a given version of this dtd. This will help to
avoid versions conflicts.
The isolation-level attribute defines the default locking isolation level used
by OJB's pessimistic locking api. All jdbc-connection-descriptor or class-descriptor
that do not define a specific isolation level will use this.
Note: This does NOT touch the jdbc-level of the connection.
-->
<!ATTLIST descriptor-repository
version (1.0) #REQUIRED
isolation-level (read-uncommitted | read-committed | repeatable-read |
serializable | optimistic | none) "read-uncommitted"
proxy-prefetching-limit CDATA "50"
>
<!--
The documentation element can be used to store arbitrary
information on all repository entries.
-->
<!ELEMENT documentation (#PCDATA)>
<!--
The attribute element allows to add custom attributes.
The jdbc-connection-descriptor element specifies the a jdbc
connection for the repository.
The object-cache element specifies the object-cache implementation
class associated with this class.
A connection-pool element may be used to define connection pool
properties for the specified JDBC connection.
A sequence-manager element may be used to
define which sequence manager implementation should be used within
the defined connection.
-->
<!ELEMENT jdbc-connection-descriptor (documentation?, attribute*,
object-cache?, connection-pool?, sequence-manager?)>
<!--
The jcdAlias attribute is a shortcut name for the defined connection
descriptor. OJB use jcdAlias as key for the defined connections.
The default-connection attribute used to define if this connection
should used as default connection with OJB. You could define only
one connection as default connection. It is also possible to set
the default connection at runtime using
PersistenceBrokerFactory#setDefaultKey(...) method.
If set 'true' you could use on PB-api a shortcut-method of the
PersistenceBrokerFactory to lookup PersistenceBroker instances.
The platform attribute is used to define the specific RDBMS
Platform. This attribute corresponds to a
org.apache.ojb.broker.platforms.PlatformXXXImpl class.
The jdbc-level attribute is used to specify the Jdbc compliance
level of the used Jdbc driver.
DEPRECATED! The eager-release attribute was adopt to solve a problem occured when
using OJB within JBoss (3.0 <= version < 3.2.2, seems to be fixed in jboss 3.2.2).
Only use within JBoss.
The batch-mode attribute allow to enable JDBC connection batch support
(if supported by used database), 'true' value allows to enable per-session
batch mode, whereas 'false' prohibits it.
PB.serviceConnectionManager.setBatchMode(...) method can be used
to switch on/off batch modus, if batch-mode was enabled. On PB.close()
OJB switch off batch modus, thus you have to do '...setBatchMode(true)' on each
obtained PB instance.
The useAutoCommit attribute allow to set how OJB uses
the autoCommit state of the used connections. The default mode
was 1.
0 - OJB ignores the autoCommit setting of the connection and do not
try to change it. This mode could be helpfully if the
connection don't let you set the autoCommit state
(e.g. using datasources from application server).
1 - [default mode] set the connection's autoCommit state temporary to 'false' if needed
(when using transaction) and restore the old state after use. In
versions before OJB 1.0.4 the autoCommit state was explicit set 'true'
when connection was created, now OJB expect that this was done by
the jdbc-driver configuration. To enable old behavior set a custom attribute
'initializationCheck' to 'true'.
2 - this setting set autoCommit explicit 'false' when connection was created.
If the ignoreAutoCommitExceptions attribute is set 'true', all
exceptions caused by setting autocommit state, will be ignored.
Default mode 'false'.
If a jndi-datasource-name for JNDI based lookup of Jdbc
connections is specified, the four attributes driver, protocol,
subprotocol, dbalias used for Jdbc DriverManager based construction
of Jdbc Connections must not be declared.
The username and password attributes are used as credentials
for obtaining a jdbc connections.
If users don't want to keep this information the
repository.xml file, they could pass user/password
using PBKey.java to obtain a PersistenceBroker
-->
<!ATTLIST jdbc-connection-descriptor
jcd-alias CDATA #REQUIRED
default-connection (true | false) "false"
platform ( Db2 | Hsqldb | Informix | MsAccess | MsSQLServer |
MySQL | Oracle | PostgreSQL | Sybase | SybaseASE |
SybaseASA | Sapdb | Firebird | Axion | NonstopSql |
Oracle9i | MaxDB ) "Hsqldb"
jdbc-level (1.0 | 2.0 | 3.0) "1.0"
eager-release (true | false) "false"
batch-mode (true | false) "false"
useAutoCommit (0 | 1 | 2) "1"
ignoreAutoCommitExceptions (true | false) "false"
jndi-datasource-name CDATA #IMPLIED
driver CDATA #IMPLIED
protocol CDATA #IMPLIED
subprotocol CDATA #IMPLIED
dbalias CDATA #IMPLIED
username CDATA #IMPLIED
password CDATA #IMPLIED
>
<!--
The object-cache element can be used to specify the ObjectCache
implementation used by OJB. There are three levels of
declaration:
1. in OJB.properties file, to declare the standard (default)
ObjectCache implementation.
2. on jdbc-connection-descriptor level, to declare ObjectCache implementation
on a per connection/user level
3. on class-descriptor level, to declare ObjectCache implementation
on a per class level
The priority of the declared object-cache elements are:
per class > per jdbc descriptor > standard
E.g. if you declare ObjectCache 'cacheDef' as standard, set
ObjectCache 'cacheA' in class-descriptor for class A and class B
does not declare an object-cache element. Then OJB use cacheA as ObjectCache
for class A and cacheDef for class B
-->
<!ELEMENT object-cache (documentation?, attribute*)>
<!--
Attribute 'class' specifies the full qualified class name of
the used ObjectCache implementation.
-->
<!ATTLIST object-cache
class CDATA #REQUIRED
>
<!--
The connection-pool element specifies the connection pooling
and low-level JDBC driver parameters.
-->
<!ELEMENT connection-pool (documentation?, attribute*)>
<!--
maxActive (default=21)
The maximum number of active connections that can be allocated from this
pool at the same time, or zero for no limit.
maxIdle (default=-1)
The maximum number of active connections that can remain idle in the pool,
without extra ones being released, or zero for no limit.
minIdle (default=0)
The minimum number of active connections that can remain idle in the pool,
without extra ones being created, or zero to create none.
Since: 1.0.4
maxWait (default=5000)
The maximum number of milliseconds that the pool will wait (when there
are no available connections) for a connection to be returned before
throwing an exception, or -1 to wait indefinitely.
Must be > 0 for timeout to actually happen in DBCP PoolingDataSource.
whenExhaustedAction (default=0/WHEN_EXHAUSTED_FAIL)
0 - fail when pool is exhausted
1 - block when pool is exhausted
2 - grow when pool is exhausted
validationQuery (default=not specified)
The SQL query that will be used to validate connections from this pool
before returning them to the caller. If specified, this query MUST be
an SQL SELECT statement that returns at least one row.
Eg:
Oracle SELECT 1 FROM DUAL
PostgreSQL SELECT 1
MySQL SELECT 1
testOnBorrow (default=true)
The indication of whether connections will be validated before being
borrowed from the pool. If the connection fails to validate, it will
be dropped from the pool, and OJB will attempt to borrow another.
testOnReturn (default=false)
The indication of whether connections will be validated before being
returned to the pool.
testWhileIdle (default=false)
The indication of whether connections will be validated by the idle object
evictor (if any). If a connection fails to validate, it will be dropped
from the pool.
timeBetweenEvictionRunsMillis (default=-1)
The number of milliseconds to sleep between runs of the idle
object evictor thread. When non-positive, no idle object evictor thread
will be run.
numTestsPerEvictionRun (default=10)
The number of objects to examine during each run of the idle object
evictor thread (if any).
minEvictableIdleTimeMillis (default=1800000)
The minimum amount of time a connection may sit idle in the pool before
it is eligable for eviction by the idle object evictor (if any).
removeAbandoned [only for ConnectionFactoryDBCPImpl] (default=false)
Flag to remove abandoned connections if they exceed the
removeAbandonedTimout.
If set to true a connection is considered abandoned and eligible for
removal if it has been idle longer than the removeAbandonedTimeout.
Setting this to true can recover db connections from poorly written
applications which fail to close a connection.
If you have enabled "removeAbandoned" then it is possible that a
connection is reclaimed by the pool because it is considered to be
abandoned. This mechanism is triggered on borrowObject (ie in OJB when
a PersistenceBroker gets a Connection) and:
(numIdle < 2) and (numActive > maxActive - 3).
The abandoned object eviction takes place before normal borrowObject
logic (there is no asynch evictor thread like for testWhileIdle).
For example maxActive=20 and 18 active connections and 1 idle connection
would trigger the "removeAbandoned". But only the active connections that
aren't used for more then "removeAbandonedTimeout" seconds are removed.
Traversing a resultset doesn't count as being used.
removeAbandonedTimeout [only for ConnectionFactoryDBCPImpl] (default=300)
Timeout in seconds before an abandoned connection can be removed.
logAbandoned [only for ConnectionFactoryDBCPImpl] (default=false)
Flag to log stack traces for application code which abandoned a
Statement or Connection.
Logging of abandoned Statements and Connections adds overhead for every
Connection open or new Statement because a stack trace has to be
generated.
Custom attributes:
<attribute attribute-name="fetchSize" attribute-value="(int)"/>
Sets a hint in the JDBC driver not to fetch more than
specified number of rows per server round trip for
any ResultSet.
Setttings different than the default (0) are especially
useful to reduce memory footprint when using drivers
that defaults to not using server-side cursors and
retrieves all rows to the JDBC client-side driver buffer.
PostgreSQL JDBC driver is a well-known example of this.
Many JDBC drivers will ignore this hint.
<attribute attribute-name="jdbc.(driver-specific attribute)"
attribute-value="(value)"/>
All attributes with names starting with "jdbc." will be
passed (without jdbc. prefix) to the JDBC DriverManager
when creating new Connection objects.
(Ignored when acquiring Connection objects through
JNDI DataSource lookup or in managed environments.)
<attribute attribute-name="dbcp.(Commons DBCP-options)"
attribute-value="(value)"/>
If using the ConnectionFactoryDBCPImpl (set in OJB.properties),
all parameters starting with "dbcp." will be made available
(without dbcp. prefix) to the ConnectionFactory for
configuring Commons DBCP accordingly.
Currently the following DBCP attributes are used:
dbcp.poolPreparedStatements (default=false)
Enable prepared statement pooling for this pool.
dbcp.maxOpenPreparedStatements (default=0/unlimited)
The maximum number of open statements that can be
allocated from the statement pool at the same time,
or zero for no limit.
dbcp.accessToUnderlyingConnectionAllowed (default=false)
Controls if the DBCP PoolGuard allows access to the underlying
connection from the JDBC-driver.
Only use when you need direct access to driver specific
extentions.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -