![]() | ![]() | ![]() | ![]() | ![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]() | ![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]()
|
The Castor configuration file Sample Configuration File Configuration For Various Databases The JDO Configuration DTD The Castor configuration fileThe database configuration specifies the means to obtain a connection to the database server, the mapping between Java classes and tables in that database server, and the service provider to use for talking to that server. The application will access the database by its given name (database/name) and will be able to persist all objects specified in the included mapping file(s). The engine attribute specifies the persistence engine for this database server. Different database servers vary in the SQL syntax and capabilites they support, and this attribute names the service provider to use. The following names are supported in Castor 1.0: Note: Castor doesn't work with JDBC-ODBC bridge from Sun. In particular, MS Access is not supported. The means to acquire a database connection is specified in one of three ways: as a JDBC 2.0 driver URL, as a JDBC 2.0 DataSource, or as a DataSource to lookup through JNDI. When Castor is used inside a J2EE application server it is recommended to use JNDI lookup (see the jndi element), allowing the application server to manage connection pooling and distributed transactions. The class mapping is included from an external mapping file, allowing multiple mappings to be included in the same database configuration, or two databases to share the same mappings. For concurrency and integrity reasons, two database configurations should never attempt to use overlapping mappings. It is recommended to use one database configuration per database server. The mapping file is specified using a URL, typically a file: URL. If the database configuration file and mapping file reside in the same directory, use a relative URL. Relative URLs also work if the database configuration and mapping files are obtained from the application JAR and reside in the same classpath. The driver element specifies the JDBC 2.0 driver for obtaining new connections to the database server. The driver is obtained from the JDBC DriverManager and must be located in the class path. The JDBC URL locates the driver and provides the access properties. Additional properties may be specified using the param element (e.g. buffer size, network protocol, etc). Use the class-name attribute to specify the driver class for automatic registration with the JDBC DriverManager. If missing, the driver must be registered in any other means, including properties file, Class.forName(), etc. For example, to configure an Oracle 8 thin driver, use: The data-source element specifies the JDBC 2.0 DataSource for obtaining new connections to the database server. DataSources are defined in the JDBC 2.0 standard extension API which is included with Castor, and implement the interface javax.sql.DataSource. The DataSource implementation class name is specified by the class-name attribute and configured through Bean-like accessor methods specified for the param element. The DTD for the param element is undefined and depends on the DataSource being used. For example, to configure a PostgreSQL 7.1 DataSource, use: The jndi element specifies the JDBC 2.0 DataSource for obtaining new connections to the database server through JNDI lookup. The JNDI environment naming context (ENC) is used to obtain a suitable DataSource.. When running inside a J2EE application server, this is the preferred method for obtaining database connections. It enables the J2EE application server to configure the connection, maintain a connection pool, and manage distributed transactions. For example, to specify a J2EE DataSource, use: Sample Configuration FileThe following configuration file uses an Oracle 8 thin JDBC driver and three mapping files: The following configuration file uses a connection obtained from the J2EE application server and a single mapping file: Configuration For Various Databases
NOTE: The JDO Configuration DTDFor validation, the configuration file should include the following document type definition. For DTD validation use: The Castor JDO database configuration DTD is: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() ![]() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |