My persistence.xml looks something like:
<persistence-unit name="fruitManager" transaction-type="RESOURCE_LOCAL">
<!-- Hibernate as provider -->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- list your persistent classes here -->
<class>com.mypackage.Fruit</class>
<!-- any more classes if there-->
<properties>
<!-- DB2 UDB -->
<property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect" />
<property name="hibernate.default_schema" value="MYSCHEMA" />
<!-- provide datasource properties -->
<property name="hibernate.connection.driver_class" value="com.ibm.db2.jcc.DB2Driver"></property>
<property name="hibernate.connection.username" value="abc"></property>
<property name="hibernate.connection.password" value="xyz"></property>
<property name="hibernate.connection.url" value="jdbc:db2://abc.xyz:50001/TESTDB"></property>
<property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider" />
<property name="c3p0.acquire_increment" value="1"></property>
<property name="c3p0.idle_test_period" value="100"></property> <!-- seconds -->
<property name="c3p0.max_size" value="100"></property>
<property name="c3p0.max_statements" value="0"></property>
<property name="c3p0.min_size" value="10"></property>
<property name="c3p0.timeout" value="100"></property> <!-- seconds -->
<!-- For Debug mode, enable it until development -->
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.use_sql_comments" value="false" />
</properties>
</persistence-unit>
And my entity class is:
@Entity
public class Fruit {
@Id
int id;
String name;
String color;
}
In my DAO the code is:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("fruitManager");
EntityManager em = emf.createEntityManager();
//get the criteria builder
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Fruit> c = cb.createQuery(Fruit.class);
Just to test whether the setup is working or not, I am running the following simple query:
// get the count of the results first
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
cq.select(cb.count(cq.from(Fruit.class)));
Long count = em.createQuery(cq).getSingleResult();
System.out.println("Number of fruits are: " + count);
However, I am getting the following error:
[10/17/11 14:02:40:069 IST] 00000076 SystemErr R <openjpa-1.0.3-SNAPSHOT-r420667:649224 fatal user error> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
I am running the example on WAS 6.1
Any hints, Ideas ???