This article provides all the information you need to use the Progress DataDirect JDBC drivers with these Java technologies. Java Platform, Enterprise Edition (Java EE) is the industry standard for developing portable, robust, scalable and secure server-side Java applications. Java EE provides web services, component model, management, and communications APIs that make it the industry standard for implementing enterprise-class service-oriented architecture (SOA) and next-generation web applications.
The Enterprise JavaBeans (EJB) architecture is a component-based architecture for development and deployment of component-based distributed applications. Applications written using Enterprise JavaBeans are scalable, transactional, and multi-user secure. These applications may be written once, and then deployed on any server platform that supports the EJB specification.
The Java Persistence API (JPA) provides a POJO (plain old Java Object) persistence model for object-relational mapping. It contains a full object/relational mapping specification supporting the use of Java language metadata annotations and/or XML descriptors to define the mapping between Java objects and a relational database. It supports a rich, SQL-like query language (which is a significant extension upon EJB Query Language) for both static and dynamic queries. It also supports the use of pluggable persistence providers.
The JPA specification was introduced by Sun as a means to combine the best ideas from many sources in the new persistence API and create a lightweight, easy to use API which is integrated into any Java EE 5 application server.
JPA provides a standardized means for mapping relational data to Java objects, while also handling the way these objects are stored in the database and removing the need to code directly to the JDBC API.
java:ds/TestDS
<
driver-class
>
com.ddtek.jdbc.sqlserver.SQLServerDriver
</
driver-class
>
<
user-name
>test</
user-name
>
<
password
>secret</
password
>
<
connection-property
name
=
"sendStringParametersAsUnicode"
>
false
</
connection-property
>
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<!-- ====================================================== -->
<!-- -->
<!-- DataDirect Data Sources -->
<!-- -->
<!-- ====================================================== -->
<!--
See the generic_ds.xml file in the doc/examples/jca folder
for examples of properties and other tags you can specify
data sources
-->
<
datasources
>
<!-- JBossTest Data Source -->
<
local-tx-datasource
>
<
jndi-name
>ds/TestDS</
jndi-name
>
<
connection-url
>
jdbc:datadirect:sqlserver://myserver:1433
</
connection-url
>
<
driver-class
>
com.ddtek.jdbc.sqlserver.SQLServerDriver
</
driver-class
>
<
user-name
>test</
user-name
>
<
password
>secret</
password
>
<!-- Driver Specific Options -->
<
connection-property
name
=
"sendStringParametersAsUnicode"
>
false
</
connection-property
>
<!--pooling parameters-->
<
min-pool-size
>5</
min-pool-size
>
<
max-pool-size
>100</
max-pool-size
>
<
blocking-timeout-millis
>5000</
blocking-timeout-millis
>
<
idle-timeout-minutes
>15</
idle-timeout-minutes
>
</
local-tx-datasource
>
</
datasources
>
InitialContext ctxt = new InitialContext();
DataSource ds = (DataSource) ctxt.lookup("java:ds/TestDS");
con = ds.getConnection();
run -c all
<
session
>
<
ejb-name
>SupportedDatabases</
ejb-name
>
<
jndi-name
>SupportedDatabasesBean</
jndi-name
>
<
local-jndi-name
>SupportedDatabasesLocal</
local-jndi-name
>
<
resource-ref
>
<
res-ref-name
>jdbc/TestDS</
res-ref-name
>
<
jndi-name
>java:/ds/TestDS</
jndi-name
>
</
resource-ref
>
</
session
>
<
defaults
>
<
datasource
>java:/ds/TestDS</
datasource
>
<
datasource-mapping
>MS SQLSERVER</
datasource-mapping
>
</
defaults
>
Adding support for JPA is achieved by defining the persistence.xml file in the META-INF directory within your application package. The persistence.xml file is the standard configuration file in JPA. In this file you define a uniquely named persistence unit which will be used by the EntityManager defined in your Entity Bean code. The provider attribute specifies the underlying implementation of the JPA EntityManager. In JBoss AS, the default and only supported / recommended JPA provider is Hibernate. The jta-data-source points to the JNDI name of the database connection to which this persistence unit maps.
For more details on the persistence.xml file, please refer to Chapter 6 of the EJB 3.0 Java Persistence API Specification
Sample persistence.xml file for this example:
<
persistence
>
<
persistence-unit
name
=
"TestDD"
>
<
provider
>org.hibernate.ejb.HibernatePersistence</
provider
>
<
jta-data-source
>java:/ds/TestDS</
jta-data-source
>
<
properties
>
property name="hibernate.dialect"
value="org.hibernate.dialect.SQLServerDialect"/>
</
properties
>
</
persistence-unit
>
</
persistence
>